first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
const e = require('express');
const express = require('express')
const app = express()
const port = 3000
// 我自己后端
app.all('*', (req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "*");
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By", 'bmy')
res.header("Content-Type", "application/json;charset=utf-8");
next();
});
app.post('/index', (req, res) => {
// var c = req.query.c;
// var data = {
// title: '测试',
// list: [
// { id:1, title: '测试1' },
// { id:2, title: '测试2' },
// { id:3, title: '测试32d3e21e21e' },
// ]
// };
// console.log(c);
// // eee(data)
// res.end(`${c}(${JSON.stringify(data)})`)
res.json({
title: '测试',
list: [
{ id: 1, title: '测试1' },
{ id: 2, title: '测试2' },
{ id: 3, title: '测试32d3e21e21e' },
]
})
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))

View File

@@ -0,0 +1,26 @@
const e = require('express');
const express = require('express')
const request = require('request')
const app = express()
const port = 8080
// 我自己后端
// 设置跨域访问
app.all('*', (req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By",'bmy')
res.header("Content-Type", "application/json;charset=utf-8");
next();
});
app.get('/my', (req, res) => {
request('http://127.0.0.1:3000/index', function (error, response, body) {
console.log('body:', body); // Print the HTML for the Google homepage.
res.json(JSON.parse(body))
});
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))

View File

@@ -0,0 +1,16 @@
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"request": "^2.88.2"
}
}