daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var express = require('express');
  2. var router = express.Router();
  3.  
  4.  
  5. router.route('/pelda1').get((req, res) => {
  6.     if(req.penz.ertek > 500){
  7.         return res.status(200).end('Vasarolhatsz');
  8.     }    
  9.     else{
  10.         return res.status(200).end('Keves');
  11.     }
  12.        
  13. }).post((req, res) => {
  14.     return res.status(404).end("not implemented");
  15. }).put((req, res) => {
  16.     return res.status(404).end("not implemented");
  17. }).delete((req, res) => {
  18.     return res.status(404).end("not implemented");
  19. });
  20.  
  21. router.route('/pelda2').get((req, res) => {    
  22.     if(req.allat.ertek === 'cica'){
  23.         return res.status(200).end('dorombol');
  24.     }    
  25.     else if (req.allat.ertek === 'kutya'){
  26.         return res.status(200).end('ugat');
  27.     }else{
  28.         return res.status(200).end('nem tudok mit kezdeni');
  29.     }
  30.    
  31. }).post((req, res) => {
  32.     return res.status(404).end("not implemented");
  33. }).put((req, res) => {
  34.     return res.status(404).end("not implemented");
  35. }).delete((req, res) => {
  36.     return res.status(404).end("not implemented");
  37. });
  38.  
  39. module.exports = router;
  40.  
  41. //---------------------------------------------- main.js
  42.  
  43. var http = require('http');
  44. var express = require('express');
  45. var bodyParser = require('body-parser');
  46. var app = express();
  47.  
  48. app.use(bodyParser.urlencoded({'extended': 'true'}));
  49.  
  50. app.get('/', function(req, res){
  51.     res.send('Hello world');
  52. });
  53.  
  54. app.use('/', require('./routes2'));
  55. app.use('/oravege', require('./routes2'));
  56.  
  57. app.listen(5000, function(){
  58.     console.log('The server is running');
  59. })
  60.  
  61. //http.createServer(function (req, res){
  62.     //res.writeHead(200, {'Content-Type': 'text/plain'});
  63.     //res.end("Hello from NodeJS");
  64. //}).listen(9615);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top