LapStore commited on
Commit
485d5a3
·
1 Parent(s): e194a66
Files changed (2) hide show
  1. app.py +12 -0
  2. index.html +13 -3
app.py CHANGED
@@ -25,9 +25,12 @@ app.state.limiter = limiter
25
  # Register the Limiter with FastAPI
26
  @app.middleware("http")
27
  async def add_process_time_header(request: Request, call_next):
 
 
28
  response = await call_next(request)
29
  return response
30
 
 
31
  @app.exception_handler(429)
32
  async def rate_limit_exceeded(request: Request, exc):
33
 
@@ -35,6 +38,15 @@ async def rate_limit_exceeded(request: Request, exc):
35
  status_code=429,
36
  content={"detail": "Too Many Requests ,please just try 3 times per hour"},
37
  )
 
 
 
 
 
 
 
 
 
38
 
39
 
40
  # Root route
 
25
  # Register the Limiter with FastAPI
26
  @app.middleware("http")
27
  async def add_process_time_header(request: Request, call_next):
28
+ client_ip = get_remote_address(request)
29
+ print(f"Request from IP: {client_ip}") # Log the client IP
30
  response = await call_next(request)
31
  return response
32
 
33
+
34
  @app.exception_handler(429)
35
  async def rate_limit_exceeded(request: Request, exc):
36
 
 
38
  status_code=429,
39
  content={"detail": "Too Many Requests ,please just try 3 times per hour"},
40
  )
41
+ '''
42
+ return JSONResponse(
43
+ status_code=429,
44
+ content={
45
+ "detail": "Too Many Requests ,please just try 3 times per hour",
46
+ "status": 0
47
+ })
48
+ '''
49
+
50
 
51
 
52
  # Root route
index.html CHANGED
@@ -2,10 +2,14 @@
2
  <body bgcolor="#00cccc">
3
  <center>
4
  <br><br><br>
5
- <form action="http://localhost:8000/items" method="post">
6
  <p><h3>Enter Image:</h3></p>
7
  type_of_filters :<p><input type="text" name="type_of_filters" /></p><br>
8
- <p><input type="submit" value="submit" /></p>
 
 
 
 
9
  </form>
10
  </center>
11
  </body>
@@ -22,4 +26,10 @@
22
 
23
  <p><input type="submit" value="submit" /></p>
24
  </form>
25
- -->
 
 
 
 
 
 
 
2
  <body bgcolor="#00cccc">
3
  <center>
4
  <br><br><br>
5
+ <form action="https://taha454-backg.hf.space/imageStep1" method="post" enctype="multipart/form-data">
6
  <p><h3>Enter Image:</h3></p>
7
  type_of_filters :<p><input type="text" name="type_of_filters" /></p><br>
8
+ blur_radius :<p><input type="text" name="blur_radius" /></p><br>
9
+ Image : <input type="file" name="image_file" required><br><br>
10
+ Background_Image : <input type="file" name="background_image" ><br><br>
11
+
12
+ <p><input type="submit" value="submit" /></p>
13
  </form>
14
  </center>
15
  </body>
 
26
 
27
  <p><input type="submit" value="submit" /></p>
28
  </form>
29
+ -->
30
+
31
+ <!--<form action="https://taha454-backg.hf.space/items" method="post">
32
+ <p><h3>Enter Image:</h3></p>
33
+ type_of_filters :<p><input type="text" name="type_of_filters" /></p><br>
34
+ <p><input type="submit" value="submit" /></p>
35
+ </form>-->