forked from abhimanyusaxena/javascript_kitchen_sink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (23 loc) · 683 Bytes
/
Copy pathindex.js
File metadata and controls
34 lines (23 loc) · 683 Bytes
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
const express = require('express');
const { createServer } = require('node:http');
const { join } = require('node:path');
const app = express();
const server = createServer(app);
const path = require('path')
const publicPath = path.join(__dirname, 'public');
console.log(publicPath);
app.use(express.static(publicPath));
app.get('/', (req, res) => {
res.sendFile(join(__dirname, 'index.html'));
});
app.post('/send_message', (req, res) => {
console.log(req.body);
res.send('ok');
});
app.get('/get_new_message', (req, res) => {
console.log(req.body);
res.send('ok');
});
server.listen(3000, () => {
console.log('server running at http://localhost:3000');
});