-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (24 loc) · 859 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require('express');
const app = express();
const port = 3000;
const summarizeText = require('./summarize.js');
// Parse JSON bodies (as sent by API clients)
app.use(express.json());
app.use(express.static('public')); // Serve static files from the 'public' directory
// Handle POST requests to the '/summarize' endpoint
app.post('/summarize', (req, res) => {
// get the text_to_summarize property from the request body
const text = req.body.text_to_summarize;
// call your summarizeText function, passing in the text from the request
summarizeText(text)
.then(response => {
res.send(response); // Send the summary text as a response
})
.catch(error => {
console.log(error.message);
});
});
// Start the server
app.listen(port, () => {
console.log('Server running at http://localhost:${port}/');
});