-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathserver.js
43 lines (36 loc) · 1.31 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const http = require('http');
const express = require('express');
const path = require('path');
const app = express();
const exec = require('child_process').exec;
var server_info = '\nServer running at http://127.0.0.1:3000/ (CTRL+C to stop)';
function run_command(command) {
console.log("\n" + command);
exec(command, (err, stdout, stderr) => console.log(stdout, server_info));
}
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
app.get('/run_my_first_test', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
res.redirect('/');
run_command("pytest my_first_test.py");
});
app.get('/run_test_demo_site', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
res.redirect('/');
run_command("pytest test_demo_site.py");
});
app.get('/run_my_first_test_with_demo_mode', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
res.redirect('/');
run_command("pytest my_first_test.py --demo_mode");
});
app.get('/run_test_demo_site_with_demo_mode', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
res.redirect('/');
run_command("pytest test_demo_site.py --demo_mode");
});
app.listen(3000, "127.0.0.1", function() {
console.log(server_info);
});