init
This commit is contained in:
29
gismeteo/app.py
Normal file
29
gismeteo/app.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
)
|
||||
Reference in New Issue
Block a user