Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from fastapi import FastAPI, Request
|
|
4 |
import uvicorn
|
5 |
import time
|
6 |
import json
|
|
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
@@ -14,13 +15,16 @@ def main():
|
|
14 |
@app.get("/chrome")
|
15 |
def chrome(url:str=None,wait:int=5,header:str=None):
|
16 |
|
17 |
-
target_url = url
|
18 |
-
wait_time = wait
|
19 |
-
header_list = header
|
20 |
|
21 |
if target_url == None:
|
22 |
return {"code": 500,"msg":"No target URL"}
|
23 |
|
|
|
|
|
|
|
24 |
options = Options()
|
25 |
options.add_argument('--headless')
|
26 |
|
|
|
4 |
import uvicorn
|
5 |
import time
|
6 |
import json
|
7 |
+
from urllib.parse import unquote
|
8 |
|
9 |
app = FastAPI()
|
10 |
|
|
|
15 |
@app.get("/chrome")
|
16 |
def chrome(url:str=None,wait:int=5,header:str=None):
|
17 |
|
18 |
+
target_url = unquote(url)
|
19 |
+
wait_time = unquote(wait)
|
20 |
+
header_list = unquote(header)
|
21 |
|
22 |
if target_url == None:
|
23 |
return {"code": 500,"msg":"No target URL"}
|
24 |
|
25 |
+
if wait_time not in range(0, 31):
|
26 |
+
return {"code": 500,"msg":"The waiting time must be between 0 and 30"}
|
27 |
+
|
28 |
options = Options()
|
29 |
options.add_argument('--headless')
|
30 |
|