Update app.py
Browse files
app.py
CHANGED
@@ -368,20 +368,22 @@ async def get_answer(q: Query ):
|
|
368 |
|
369 |
|
370 |
def do_ML2(id:str,text:str,host:str, trycount:int):
|
371 |
-
|
372 |
-
|
373 |
-
# starttime=time.time()
|
374 |
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
|
|
|
|
381 |
while True:
|
382 |
-
|
383 |
-
|
384 |
-
|
|
|
385 |
try:
|
386 |
textarea = driver.find_element(By.CSS_SELECTOR, "textarea")
|
387 |
textarea.send_keys(text)
|
@@ -394,9 +396,10 @@ def do_ML2(id:str,text:str,host:str, trycount:int):
|
|
394 |
|
395 |
# time.sleep(2)
|
396 |
while True:
|
397 |
-
|
398 |
-
|
399 |
-
|
|
|
400 |
|
401 |
time.sleep(0.2)
|
402 |
# currtime= time.time()
|
@@ -420,7 +423,7 @@ def do_ML2(id:str,text:str,host:str, trycount:int):
|
|
420 |
except:
|
421 |
print("Error")
|
422 |
driver.delete_all_cookies()
|
423 |
-
if trycount>
|
424 |
|
425 |
return "Request Could not be proceed"
|
426 |
driver.quit()
|
|
|
368 |
|
369 |
|
370 |
def do_ML2(id:str,text:str,host:str, trycount:int):
|
371 |
+
|
372 |
+
starttime=time.time()
|
|
|
373 |
|
374 |
+
options = ChromeOptions()
|
375 |
+
options.add_argument('--no-sandbox')
|
376 |
+
options.add_argument('-headless')
|
377 |
+
service = Service()
|
378 |
+
driver = webdriver.Chrome(options= options,service=service)
|
379 |
+
driver.get("https://talkai.info/image/")
|
380 |
+
try:
|
381 |
+
|
382 |
while True:
|
383 |
+
currtime= time.time()
|
384 |
+
if(currtime>starttime+5):
|
385 |
+
raise ValueError("h")
|
386 |
+
# return "Requested Could not be proceed"
|
387 |
try:
|
388 |
textarea = driver.find_element(By.CSS_SELECTOR, "textarea")
|
389 |
textarea.send_keys(text)
|
|
|
396 |
|
397 |
# time.sleep(2)
|
398 |
while True:
|
399 |
+
currtime= time.time()
|
400 |
+
if(currtime>starttime+40):
|
401 |
+
raise ValueError("j")
|
402 |
+
return "Requested Could not be proceed"
|
403 |
|
404 |
time.sleep(0.2)
|
405 |
# currtime= time.time()
|
|
|
423 |
except:
|
424 |
print("Error")
|
425 |
driver.delete_all_cookies()
|
426 |
+
if trycount>4:
|
427 |
|
428 |
return "Request Could not be proceed"
|
429 |
driver.quit()
|