更改端口为8443

This commit is contained in:
xbh 2025-11-07 16:53:52 +08:00
parent 112a41d372
commit 74cde01f1b
7 changed files with 64 additions and 9 deletions

View File

@ -1,9 +1,29 @@
from flask import Flask, jsonify
from flask import Flask, jsonify, send_from_directory
from flask_cors import CORS
import logging
import os
app = Flask(__name__)
# 配置静态文件目录为dist
# 说明:这里指向后端目录中的 dist前端构建产物应复制或输出到此
dist_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'dist'))
app.static_folder = dist_dir
# 为 SPA 提供静态文件与回退到 index.html 的路由
@app.route('/')
def serve_index():
# 返回构建后的前端入口文件
return send_from_directory(app.static_folder, 'index.html')
@app.route('/<path:path>')
def serve_static_or_fallback(path):
# 如果请求的文件存在则直接返回,否则回退到 index.html用于前端路由
file_path = os.path.join(app.static_folder, path)
if os.path.isfile(file_path):
return send_from_directory(app.static_folder, path)
return send_from_directory(app.static_folder, 'index.html')
CORS(app) # 允许跨域访问
# 配置日志
@ -29,6 +49,6 @@ app.register_blueprint(article_bp)
if __name__ == '__main__':
print("启动主程序服务...")
print("服务地址: http://localhost:5001")
print("服务地址: http://localhost:8443")
app.run(host='0.0.0.0', port=5001, debug=True)
app.run(host='0.0.0.0', port=8443, debug=True)

View File

@ -197,7 +197,7 @@ def format_interaction_count(count):
def format_mix_item(doc, target_date=None):
"""格式化合集数据项 - 完全按照数据库原始字段返回"""
mix_name = doc.get("mix_name", "")
mix_name = doc.get("mix_name", "") or doc.get("title", "")
# 计算总点赞数
episode_details = doc.get("episode_details", [])
@ -217,6 +217,7 @@ def format_mix_item(doc, target_date=None):
"_id": str(doc.get("_id", "")),
"batch_time": format_time(doc.get("batch_time")),
"mix_name": mix_name,
"title": mix_name,
"video_url": doc.get("video_url", ""),
"playcount": doc.get("playcount", ""),
"play_vv": doc.get("play_vv", 0),

View File

@ -11,7 +11,8 @@
"axios": "^1.12.2",
"bootstrap": "^5.3.0-alpha1",
"bootstrap-icons": "^1.13.1",
"vue": "^3.5.22"
"vue": "^3.5.22",
"vue-router": "^4.6.3"
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.1",
@ -1333,6 +1334,11 @@
"@vue/shared": "3.5.22"
}
},
"node_modules/@vue/devtools-api": {
"version": "6.6.4",
"resolved": "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.6.4.tgz",
"integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g=="
},
"node_modules/@vue/devtools-core": {
"version": "8.0.3",
"resolved": "https://registry.npmmirror.com/@vue/devtools-core/-/devtools-core-8.0.3.tgz",
@ -2643,6 +2649,20 @@
}
}
},
"node_modules/vue-router": {
"version": "4.6.3",
"resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.6.3.tgz",
"integrity": "sha512-ARBedLm9YlbvQomnmq91Os7ck6efydTSpRP3nuOKCvgJOHNrhRoJDSKtee8kcL1Vf7nz6U+PMBL+hTvR3bTVQg==",
"dependencies": {
"@vue/devtools-api": "^6.6.4"
},
"funding": {
"url": "https://github.com/sponsors/posva"
},
"peerDependencies": {
"vue": "^3.5.0"
}
},
"node_modules/wsl-utils": {
"version": "0.1.0",
"resolved": "https://registry.npmmirror.com/wsl-utils/-/wsl-utils-0.1.0.tgz",
@ -3459,6 +3479,11 @@
"@vue/shared": "3.5.22"
}
},
"@vue/devtools-api": {
"version": "6.6.4",
"resolved": "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.6.4.tgz",
"integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g=="
},
"@vue/devtools-core": {
"version": "8.0.3",
"resolved": "https://registry.npmmirror.com/@vue/devtools-core/-/devtools-core-8.0.3.tgz",
@ -4276,6 +4301,14 @@
"@vue/shared": "3.5.22"
}
},
"vue-router": {
"version": "4.6.3",
"resolved": "https://registry.npmmirror.com/vue-router/-/vue-router-4.6.3.tgz",
"integrity": "sha512-ARBedLm9YlbvQomnmq91Os7ck6efydTSpRP3nuOKCvgJOHNrhRoJDSKtee8kcL1Vf7nz6U+PMBL+hTvR3bTVQg==",
"requires": {
"@vue/devtools-api": "^6.6.4"
}
},
"wsl-utils": {
"version": "0.1.0",
"resolved": "https://registry.npmmirror.com/wsl-utils/-/wsl-utils-0.1.0.tgz",

View File

@ -15,7 +15,8 @@
"axios": "^1.12.2",
"bootstrap": "^5.3.0-alpha1",
"bootstrap-icons": "^1.13.1",
"vue": "^3.5.22"
"vue": "^3.5.22",
"vue-router": "^4.6.3"
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.1",

View File

@ -58,7 +58,7 @@ const initDate = () => {
}
// APIURL
const API_BASE_URL = 'http://localhost:5001/api'
const API_BASE_URL = 'http://159.75.150.210:8443/api'
//
const fetchRankingData = async () => {

View File

@ -77,7 +77,7 @@ const fetchRankingData = async () => {
params.classification_type = selectedCategory.value
}
const response = await axios.get('http://localhost:5001/api/rank/videos', {
const response = await axios.get('http://159.75.150.210:8443/api/rank/videos', {
params: params
})

View File

@ -17,7 +17,7 @@ export default defineConfig({
port: 5174,
proxy: {
'/api': {
target: 'http://localhost:5001',
target: 'http://159.75.150.210:8443',
changeOrigin: true,
secure: false
}