Advertisement
leomaster

prokopis sample

Apr 11th, 2021
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var express = require('express')
  2. var fs = require('fs')
  3. var app = express()
  4.  
  5. app.use(express.bodyParser())
  6.  
  7. app.get('/', function(request, response) {
  8.   console.log('GET /')
  9.   var html = `
  10.     <html>
  11.         <body>
  12.             <form method="post" action="http://localhost:3000">Name:
  13.                 <input type="text" name="name" />
  14.                 <input type="submit" value="Submit" />
  15.             </form>
  16.         </body>
  17.     </html>`
  18.   response.writeHead(200, {'Content-Type': 'text/html'})
  19.   response.end(html)
  20. })
  21.  
  22. app.post('/', function(request, response) {
  23.   console.log('POST /')
  24.   console.dir(request.body)
  25.   response.writeHead(200, {'Content-Type': 'text/html'})
  26.   response.end('thanks')
  27. })
  28.  
  29. const port = 3000
  30. app.listen(port)
  31. console.log(`Listening at http://localhost:${port}`)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement