first commit
This commit is contained in:
commit
be29a44b9e
|
@ -0,0 +1,3 @@
|
|||
node_modules/
|
||||
.DS_Store
|
||||
.env
|
|
@ -0,0 +1,31 @@
|
|||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
const app = express();
|
||||
const port = 3001;
|
||||
|
||||
// Parse JSON bodies
|
||||
app.use(bodyParser.json());
|
||||
|
||||
// Handle POST requests to '/post'
|
||||
app.post('/post', (req, res) => {
|
||||
// Access the POST data sent in the request body
|
||||
const postData = req.body;
|
||||
|
||||
// Process the received data
|
||||
console.log('Received data:', postData);
|
||||
|
||||
// Respond with a simple message
|
||||
res.send('Received your POST request!');
|
||||
});
|
||||
|
||||
app.get('/get', (req, res) => {
|
||||
// Respond with a simple message
|
||||
console.log('Received GET request');
|
||||
res.status(200).send({ message: 'Hello World!' });
|
||||
})
|
||||
|
||||
// Start the server
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is running on http://localhost:${port}`);
|
||||
});
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "electric",
|
||||
"version": "1.0.0",
|
||||
"description": "electric backend",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "nodemon index.js",
|
||||
"dev": "nodemon index.js"
|
||||
},
|
||||
"author": "kicap",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"express": "^4.19.2",
|
||||
"express-form-data": "^2.0.23",
|
||||
"nodemon": "^3.1.0"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue