-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
48 lines (35 loc) · 1.04 KB
/
app.js
File metadata and controls
48 lines (35 loc) · 1.04 KB
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
const express = require('express');
const cors = require('cors');
const app = express();
app.use(express.json());
app.use(cors());
// app.get('/', (req, res) => {
// res.send("to get data go to /api/questions");
// });
app.get('/api/questions', (req, res) => {
const questions = [
{
id: 1,
que: "In how many seasons this character has appeared?",
options: [ 2, 4, 5, 1],
},
{
id: 2,
que: "What is the status of character?",
options: ["Deceased", "Alive", "Presumed dead"],
}
];
res.json(questions);
});
// for hosting on heroku
const path = require('path');
// Serve any static files
app.use(express.static(path.join(__dirname, 'client/build')));
// Handle React routing, return all requests to React app
app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log("running on port", PORT);
})