first commit
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Executable file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
node_modules/
 | 
			
		||||
.DS_Store
 | 
			
		||||
.env
 | 
			
		||||
							
								
								
									
										31
									
								
								index.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								index.js
									
									
									
									
									
										Executable file
									
								
							@ -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}`);
 | 
			
		||||
});
 | 
			
		||||
							
								
								
									
										1255
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										1255
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										18
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							@ -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"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user