mirror of https://github.com/01-edu/public.git
add support to override student solution path for local testing
This commit is contained in:
parent
40c9d143e2
commit
636c1d84e6
|
@ -18,6 +18,7 @@ const config = {
|
|||
],
|
||||
}
|
||||
|
||||
const solutionPath = process.env.SOLUTION_PATH || '/jail/student'
|
||||
const mediaTypes = {
|
||||
jpg: 'image/jpeg',
|
||||
png: 'image/png',
|
||||
|
@ -31,7 +32,7 @@ const server = http
|
|||
.createServer(({ url, method }, response) => {
|
||||
console.log(method + ' ' + url)
|
||||
const filepath = url.endsWith(`${exercise}/${exercise}.js`)
|
||||
? path.join('/jail/student', url.slice(exercise.length + 1))
|
||||
? path.join(solutionPath, url.slice(exercise.length + 1))
|
||||
: path.join('./subjects', url)
|
||||
const ext = path.extname(filepath)
|
||||
response.setHeader('Content-Type', mediaTypes[ext.slice(1)] || 'text/plain')
|
||||
|
|
Loading…
Reference in New Issue