File tree Expand file tree Collapse file tree 3 files changed +2907
-0
lines changed Expand file tree Collapse file tree 3 files changed +2907
-0
lines changed Original file line number Diff line number Diff line change 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+ } )
You can’t perform that action at this time.
0 commit comments