Compare commits

...

2 Commits

Author SHA1 Message Date
ycg
89173384bd 3 2025-08-25 16:26:01 +08:00
ycg
5e161243ac 2 2025-08-25 15:48:48 +08:00
3 changed files with 9 additions and 6 deletions

View File

@ -5,5 +5,4 @@ COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt # 禁用缓存减小体积
COPY . .
EXPOSE 5000
USER appuser # 切换非 root 用户
CMD ["python main.py"]
CMD ["python3","./main.py"]

View File

@ -3,8 +3,10 @@ from flask import Flask
import time
import random
import requests
from flask_cors import CORS
app = Flask(__name__)
CORS(app, supports_credentials=True)
cache = set()
scheduler = BackgroundScheduler()
@ -20,7 +22,6 @@ def init_scheduler():
def fetch(api):
"""调用百度热搜 API (示例接口,需替换实际 API Key) [6](@ref)"""
url = api[1]['url']
hotList = api[1]['hot']
random.shuffle(hotList)
@ -47,10 +48,12 @@ def get_random_hot_searches():
continue
else:
cache.add(hot['title'])
return {'code': 200, 'data': [hot]}
res = {'code': 200, 'data': [hot]}
print("返回热搜词"+str(hot['title']))
return res
return [{"title": "所有平台数据均重复或无数据", "source": "system"}]
if __name__ == "__main__":
# init_scheduler()
app.run(debug=True)
app.run(host="0.0.0.0", port="5000")

View File

@ -1,3 +1,4 @@
requests~=2.32.3
APScheduler~=3.11.0
Flask~=2.2.3
Flask~=2.2.3
Flask-Cors~=4.0.1