Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. const express = require('express');
  2. const bodyParser = require('body-parser');
  3. let app = express();
  4. let path = require('path');
  5.  
  6.  
  7. //app.use(express.static(process.argv[3]||path.join(__dirname, 'public')));
  8. app.use(bodyParser.json());
  9. app.use(bodyParser.urlencoded({ extended: true }));
  10. app.use((req, res, next) => {
  11. res.header('Content-Type', 'application/json');
  12. next();
  13. });
  14.  
  15. app.use(express.static(__dirname + '/'));
  16.  
  17. app.get('/index', (req, res) => {
  18. res.sendFile(__dirname + '/index.html');
  19.  
  20. })
  21.  
  22. app.get('/search', (req, res) => {
  23. code = req.query
  24. ver = JSON.stringify({ code }, null, '');
  25. // res.send(JSON.stringify({ code }, null, ''));
  26. res.redirect('/res');
  27.  
  28. })
  29. app.get('/res', (req, res) => {
  30. res.send(ver)
  31.  
  32. })
  33.  
  34. app.listen(process.argv[2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement