Spaces:
Runtime error
Runtime error
# import main things | |
from fastapi import Depends, FastAPI, Body | |
from fastapi.responses import JSONResponse, HTMLResponse | |
from uvicorn import run | |
from utils import predict | |
from fastapi_limiter import FastAPILimiter | |
from fastapi_limiter.depends import RateLimiter | |
import redis.asyncio as aioredis | |
# initing things | |
app = FastAPI() | |
async def startup(): | |
redis = aioredis.from_url("redis://localhost", encoding="utf-8", decode_responses=True) | |
await FastAPILimiter.init(redis) | |
async def root(): | |
return JSONResponse({"detail":"Not Found"}, 404) | |
async def v(): return {"v": 4, "l": ""} | |
async def resolveGet(): | |
return JSONResponse({"detail":"Use POST instead GET"}, 400) | |
async def resolvePost(data = Body()): | |
return await predict(data["url"]) | |
run(app, host="0.0.0.0", port=80) | |