30 lines
562 B
Python
30 lines
562 B
Python
from os import environ
|
|
|
|
import uvicorn
|
|
from fastapi import FastAPI
|
|
|
|
from gismeteo import custom_doc
|
|
from gismeteo.api import GismeteoApi
|
|
|
|
|
|
app = FastAPI(docs_url=None, redoc_url=None)
|
|
custom_doc.apply(app)
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {}
|
|
|
|
|
|
@app.get("/weather/{location_id}")
|
|
async def get_weather(location_id: str):
|
|
api = GismeteoApi()
|
|
result = await api.today(location_id)
|
|
return [item._asdict() for item in result]
|
|
|
|
|
|
def run():
|
|
uvicorn.run(
|
|
"gismeteo.app:app", host="0.0.0.0", port=8000, reload="DEBUG" in environ
|
|
)
|