/
server.js
52 lines (42 loc) · 1.39 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
44
45
46
47
48
49
50
51
/*
var admin = require('firebase-admin');
var express = require('express');
var app = express();
var path = require('path');
var router = express.Router();
var serviceAccount = require("./serviceAccountKey.json");
app.use(express.static(path.join(__dirname, 'www')));
app.get('*', function(req,res){
res.sendFile('./www/index.html');
});
/*
app.stdout.on('data', function(data){
}); //do stuff with returned python script
var server = app.listen(8080, function() {
console.log('Server running at http://localhost:8080');
});
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://tardy-ccd34.firebaseio.com"
});
*/
const express = require('express')
const path = require('path')
const port = process.env.PORT || 8080
const app = express()
// serve static assets normally
app.use(express.static(__dirname + '/www'))
// handle every other route with index.html, which will contain
// a script tag to your application's JavaScript file(s).
app.get('*', function (request, response){
if (request.url == '/api/data') {
console.log('Data request')
//var spawn = require("child_process").spawn;
//var process = spawn('python', ["./backend/runPredict.py", uid, target, time]);
//process.stdout.on('data', function(data){
//});
}
response.sendFile(path.resolve(__dirname, 'www', 'index.html'))
})
app.listen(port)
console.log("server started on port " + port)