Advertisement
Guest User

lol

a guest
Jun 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require('express');
  2. const https = require('https');
  3. const exphbs = require('express-handlebars');
  4. const Handlebars = require('handlebars');
  5. const PythonShell = require('python-shell');
  6. const app = express();
  7.  
  8. app.engine('handlebars', exphbs({defaultLayout: 'main'}));
  9. app.set('view engine', 'handlebars');
  10. app.use(express.static('public'));
  11.  
  12. app.get('/', function (req, res) {
  13.     res.render('home');
  14. })
  15.  
  16. app.get('/result', function (req, res) {
  17.  
  18.     console.log(req.query.id);
  19.     let pyshell = new PythonShell.run('img_scrapper.py');
  20.     pyshell.send(req.query.id);
  21.     pyshell.on('message', function (message) {
  22.     // received a message sent from the Python script (a simple "print" statement)
  23.     console.log(message);
  24.     });
  25.     pyshell.end(function (err) {
  26.     if (err) throw err;
  27.     console.log('finished');
  28.     });
  29.     res.render('result');
  30. })
  31.  
  32. app.listen(3000, function () {
  33.     console.log('Running app');
  34. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement