-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.js
53 lines (42 loc) · 1.53 KB
/
index.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
52
53
const express = require('express');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
process.env.PORT = process.env.PORT || 3000;
const app = express();
/*
* =======================================================================
* ================ REACT config =====================
* =======================================================================
*/
app.use('/', express.static('public'));
/*
* =======================================================================
* ============== normal express routes go here ========================
* =======================================================================
*/
app.get('/banana', (request, response)=>{
response.send("ehllo");
});
/*
* =======================================================================
* ============== react express route ========================
* =======================================================================
*/
app.get('/react', (req, res) => {
const myHtml = `
<html>
<body>
<h1>Wow, react</h1>
<script type="text/javascript" src="/main.js"></script>
</body>
</html>
`;
res.send( myHtml );
});
/*
* =======================================================================
* ============ LISTEN =============
* =======================================================================
*/
app.listen(process.env.PORT, () => {
console.log(`ssssserver is now running on http://localhost:${process.env.PORT}`);
});