42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
var port = 25776;
|
|
if (process.argv.length >= 3){
|
|
port = process.argv[2];
|
|
}
|
|
const express = require('express');
|
|
const app = express();
|
|
var bodyParser = require("body-parser");
|
|
var cookieParser = require("cookie-parser");
|
|
const path = require('path');
|
|
const { execFile } = require('child_process');
|
|
const fs = require('fs');
|
|
|
|
const cors = require('cors');
|
|
app.use(cors({origin:'http://localhost:4200', credentials: true}));
|
|
app.options('*', cors());
|
|
|
|
app.get('/secret',function(req,res){
|
|
res.json("You found the secret!");
|
|
});
|
|
|
|
app.use(cookieParser("df88&DK!!Odmsk.snsh!~dsf00)SDF'"));
|
|
app.use(bodyParser.urlencoded({ extended: false}));
|
|
app.use(bodyParser.json());
|
|
|
|
app.use('/api2', require('./routes/api/api'));
|
|
|
|
var wwwFolder = path.join(__dirname,"../www");
|
|
console.log(wwwFolder);
|
|
|
|
app.use(express.static(wwwFolder));
|
|
|
|
app.get('/*', function (req, res) {
|
|
console.log(__dirname);
|
|
console.log(req.originalUrl);
|
|
res.sendFile(path.join(__dirname, '../www', 'index.html'));
|
|
})
|
|
|
|
app.listen(port, function () {
|
|
console.log('listening on port '+ port +'!');
|
|
})
|
|
|