AEUPH commited on
Commit
26c1721
·
verified ·
1 Parent(s): 7607e24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from fastapi import FastAPI, Request, HTTPException
2
  import httpx
3
  from starlette.responses import RedirectResponse
4
 
@@ -9,6 +9,14 @@ async def forward(request: Request):
9
  # Extract query parameters as a dictionary
10
  query_params = dict(request.query_params)
11
 
 
 
 
 
 
 
 
 
12
  # Extract the URL to forward to (param1)
13
  forward_url = query_params.pop('param1', None)
14
 
 
1
+ from fastapi import FastAPI, Request, HTTPException, Response
2
  import httpx
3
  from starlette.responses import RedirectResponse
4
 
 
9
  # Extract query parameters as a dictionary
10
  query_params = dict(request.query_params)
11
 
12
+ # If no parameters are submitted, show help information
13
+ if not query_params:
14
+ return {
15
+ "error": "No parameters provided.",
16
+ "help": "This endpoint forwards parameters to a specified URL. "
17
+ "Use `param1` to specify the URL to forward to, followed by any other parameters you wish to forward."
18
+ }
19
+
20
  # Extract the URL to forward to (param1)
21
  forward_url = query_params.pop('param1', None)
22