52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
const express = require('express')
|
|
const app = express()
|
|
const request = require("./src/http/http");
|
|
const config = require("./src/config/config");
|
|
|
|
//解决跨域
|
|
app.use((req, res, next) => {
|
|
// 设置是否运行客户端设置 withCredentials
|
|
// 即在不同域名下发出的请求也可以携带 cookie
|
|
res.header("Access-Control-Allow-Credentials", true)
|
|
// 第二个参数表示允许跨域的域名,* 代表所有域名
|
|
res.header('Access-Control-Allow-Origin', '*')//配置80端口跨域
|
|
res.header('Access-Control-Allow-Methods', 'GET, PUT, POST, OPTIONS') // 允许的 http 请求的方法
|
|
// 允许前台获得的除 Cache-Control、Content-Language、Content-Type、Expires、Last-Modified、Pragma 这几张基本响应头之外的响应头
|
|
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With')
|
|
if (req.method == 'OPTIONS') {
|
|
res.sendStatus(200)
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
app.get('/', async (req, res) => {
|
|
let { page } = req.query
|
|
let data = await request.post(config.visionProfileLikePhotoList, {
|
|
page: "profile",
|
|
pcursor: page
|
|
});
|
|
res.json(data)
|
|
})
|
|
|
|
app.get('/tj', async (req, res) => {
|
|
let { feeds } = await request.post(config.visionNewRecoFeed, {
|
|
dailyFirstPage: false
|
|
});
|
|
let result = []
|
|
feeds.forEach(v => {
|
|
result.push({
|
|
video_introduce: v.photo.caption,
|
|
video_url: v.photo.photoH265Url
|
|
})
|
|
});
|
|
|
|
res.json(result)
|
|
|
|
|
|
})
|
|
|
|
app.listen(3030, () => {
|
|
console.log(`http://127.0.0.1:3030`)
|
|
})
|