imperialwool commited on
Commit
b00bedf
·
1 Parent(s): dfae564

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -14
main.py CHANGED
@@ -4,32 +4,22 @@ from fastapi.responses import JSONResponse, HTMLResponse
4
  from uvicorn import run
5
  from utils import predict
6
 
7
- from fastapi_limiter import FastAPILimiter
8
- from fastapi_limiter.depends import RateLimiter
9
-
10
- import redis.asyncio as aioredis
11
-
12
  # initing things
13
  app = FastAPI()
14
 
15
- @app.on_event("startup")
16
- async def startup():
17
- redis = aioredis.from_url("redis://localhost", encoding="utf-8", decode_responses=True)
18
- await FastAPILimiter.init(redis)
19
-
20
- @app.get("/", dependencies=[Depends(RateLimiter(times=5, minutes=1))])
21
- @app.post("/", dependencies=[Depends(RateLimiter(times=5, minutes=1))])
22
  async def root():
23
  return JSONResponse({"detail":"Not Found"}, 404)
24
 
25
  @app.get("/amino-captcha-ocr/api/v1/autoregister/version")
26
  async def v(): return {"v": 4, "l": ""}
27
 
28
- @app.get("/amino-captcha-ocr/api/v1/predict", dependencies=[Depends(RateLimiter(times=5, minutes=1))])
29
  async def resolveGet():
30
  return JSONResponse({"detail":"Use POST instead GET"}, 400)
31
 
32
- @app.post("/amino-captcha-ocr/api/v1/predict", dependencies=[Depends(RateLimiter(times=5, minutes=1))])
33
  async def resolvePost(data = Body()):
34
  return await predict(data["url"])
35
 
 
4
  from uvicorn import run
5
  from utils import predict
6
 
 
 
 
 
 
7
  # initing things
8
  app = FastAPI()
9
 
10
+ @app.get("/")
11
+ @app.post("/")
 
 
 
 
 
12
  async def root():
13
  return JSONResponse({"detail":"Not Found"}, 404)
14
 
15
  @app.get("/amino-captcha-ocr/api/v1/autoregister/version")
16
  async def v(): return {"v": 4, "l": ""}
17
 
18
+ @app.get("/amino-captcha-ocr/api/v1/predict")
19
  async def resolveGet():
20
  return JSONResponse({"detail":"Use POST instead GET"}, 400)
21
 
22
+ @app.post("/amino-captcha-ocr/api/v1/predict")
23
  async def resolvePost(data = Body()):
24
  return await predict(data["url"])
25