qotnews/readerserver/main.js

31 lines
905 B
JavaScript
Raw Normal View History

const port = 33843;
2019-08-21 03:49:06 +00:00
const express = require('express');
const app = express();
2020-11-10 01:56:21 +00:00
const simple = require('./scraper/simple');
2019-08-21 03:49:06 +00:00
app.use(express.urlencoded({ extended: true }));
2020-11-10 01:56:21 +00:00
app.get('/', (req, res) => {
// const routes = ['/', '/details', '/browser', '/browser/details', '/browser/comments'];
const routes = ['/', '/details'];
const html = routes.map(route => `
<form method="POST" action="${route}" accept-charset="UTF-8">
<fieldset>
<legend>route: POST ${route}</legend>
<input name="url">
<button type="submit">SUBMIT</button>
</fieldset>
</form>`).join('<hr />');
res.send(html);
});
app.post('/', simple.scrape);
app.post('/details', simple.details);
// app.post('/browser', browser.scrape);
// app.post('/browser/details', browser.details);
// app.post('/browser/comments', browser.comments);
2019-08-21 03:49:06 +00:00
app.listen(port, () => {
console.log(`Example app listening on port ${port}!`);
});