Skip to content

Commit 1a63628

Browse files
webserver files added to repo
1 parent 65f4751 commit 1a63628

File tree

3 files changed

+2907
-0
lines changed

3 files changed

+2907
-0
lines changed

lcowebserver/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Part of exercise file for go lang course at
3+
https://web.learncodeonline.in
4+
*/
5+
6+
const express = require('express')
7+
const app = express()
8+
const port = 8000
9+
10+
app.use(express.json());
11+
app.use(express.urlencoded({extended: true}));
12+
13+
app.get('/', (req, res) => {
14+
res.status(200).send("Welcome to LearnCodeonline server")
15+
})
16+
17+
app.get('/get', (req, res) => {
18+
res.status(200).json({message: "Hello from learnCodeonline.in"})
19+
})
20+
21+
22+
app.post('/post', (req, res) => {
23+
let myJson = req.body; // your JSON
24+
25+
res.status(200).send(myJson);
26+
})
27+
28+
app.post('/postform', (req, res) => {
29+
res.status(200).send(JSON.stringify(req.body));
30+
})
31+
32+
33+
app.listen(port, () => {
34+
console.log(`Example app listening at http://localhost:${port}`)
35+
})

0 commit comments

Comments
 (0)