yin_home/main.py
2025-02-11 18:03:58 +08:00

32 lines
901 B
Python

from fastapi import FastAPI
import uvicorn
from utils import query_weather
from utils.log import Log
app = FastAPI(title="yin_home文档")
@app.get('/weather', tags=["获取天气数据"], summary="返回实时天气数据")
def weather():
response = query_weather.query_weather()
return response
@app.get('/weather_all', tags=["获取天气数据"], summary="返回天气预报数据")
def weather_all():
response = query_weather.query_weather(extensions='all')
return response
@app.get('/weather_flag', tags=["获取天气数据"], summary="返回实时天气数据状态码")
def weather_flag():
log = Log().getlog()
response = query_weather.query_weather()
weather = response['lives'][0]['weather']
log.info(weather)
return 1 if '' in weather else 0
if __name__ == '__main__':
uvicorn.run(app='main:app', host='0.0.0.0', port=1314, reload=True)