fastapi / app.py
steveagi's picture
import pgsoft
e63ff3b
raw
history blame
605 Bytes
from fastapi import FastAPI
import time
from datetime import datetime
import asyncio
from pgsoft.pgconst.const import service_list
app = FastAPI()
@app.get("/")
async def root():
return {"message": "PGAI API"}
@app.get("/test")
def test():
print(f"[{datetime.now()}] test")
print(service_list)
return {"a": 1}
@app.get("/info_sync")
def info_sync():
print(f"[{datetime.now()}] sync")
time.sleep(5)
return {"message": "sync"}
@app.get("/info_async")
async def info_async():
print(f"[{datetime.now()}] async")
await asyncio.sleep(5)
return {"message": "async"}