Compare commits
No commits in common. "89173384bdd89ebce0f25a8c2a7fd97682681aef" and "a7a3a9a4a875cc3f30b5f3dd6c631be7d7e6bd15" have entirely different histories.
89173384bd
...
a7a3a9a4a8
@ -5,4 +5,5 @@ COPY requirements.txt .
|
|||||||
RUN pip install --no-cache-dir -r requirements.txt # 禁用缓存减小体积
|
RUN pip install --no-cache-dir -r requirements.txt # 禁用缓存减小体积
|
||||||
COPY . .
|
COPY . .
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
CMD ["python3","./main.py"]
|
USER appuser # 切换非 root 用户
|
||||||
|
CMD ["python main.py"]
|
||||||
9
main.py
9
main.py
@ -3,10 +3,8 @@ from flask import Flask
|
|||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
import requests
|
import requests
|
||||||
from flask_cors import CORS
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app, supports_credentials=True)
|
|
||||||
cache = set()
|
cache = set()
|
||||||
scheduler = BackgroundScheduler()
|
scheduler = BackgroundScheduler()
|
||||||
|
|
||||||
@ -22,6 +20,7 @@ def init_scheduler():
|
|||||||
|
|
||||||
|
|
||||||
def fetch(api):
|
def fetch(api):
|
||||||
|
"""调用百度热搜 API (示例接口,需替换实际 API Key) [6](@ref)"""
|
||||||
url = api[1]['url']
|
url = api[1]['url']
|
||||||
hotList = api[1]['hot']
|
hotList = api[1]['hot']
|
||||||
random.shuffle(hotList)
|
random.shuffle(hotList)
|
||||||
@ -48,12 +47,10 @@ def get_random_hot_searches():
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
cache.add(hot['title'])
|
cache.add(hot['title'])
|
||||||
res = {'code': 200, 'data': [hot]}
|
return {'code': 200, 'data': [hot]}
|
||||||
print("返回热搜词"+str(hot['title']))
|
|
||||||
return res
|
|
||||||
return [{"title": "所有平台数据均重复或无数据", "source": "system"}]
|
return [{"title": "所有平台数据均重复或无数据", "source": "system"}]
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# init_scheduler()
|
# init_scheduler()
|
||||||
app.run(host="0.0.0.0", port="5000")
|
app.run(debug=True)
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
requests~=2.32.3
|
requests~=2.32.3
|
||||||
APScheduler~=3.11.0
|
APScheduler~=3.11.0
|
||||||
Flask~=2.2.3
|
Flask~=2.2.3
|
||||||
Flask-Cors~=4.0.1
|
|
||||||
Loading…
Reference in New Issue
Block a user