Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,26 @@ from flask import Flask, render_template, request, jsonify
|
|
| 2 |
from form_filler import FormFiller
|
| 3 |
import threading
|
| 4 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
|
|
|
|
| 9 |
app = Flask(__name__)
|
|
|
|
|
|
|
| 10 |
form_filler = FormFiller()
|
| 11 |
|
|
|
|
| 12 |
@app.route('/')
|
| 13 |
def index():
|
| 14 |
return render_template('index.html')
|
|
@@ -19,7 +32,10 @@ def start_form_filling():
|
|
| 19 |
iterations = int(request.json['iterations'])
|
| 20 |
|
| 21 |
def run_form_filler():
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
form_filler.total_iterations = iterations
|
| 25 |
form_filler.iterations_left = iterations
|
|
@@ -58,6 +74,5 @@ def get_status():
|
|
| 58 |
"environment_status": list(form_filler.environment_status)
|
| 59 |
})
|
| 60 |
|
| 61 |
-
|
| 62 |
if __name__ == '__main__':
|
| 63 |
app.run()
|
|
|
|
| 2 |
from form_filler import FormFiller
|
| 3 |
import threading
|
| 4 |
import os
|
| 5 |
+
import logging
|
| 6 |
+
import random
|
| 7 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 8 |
+
import time
|
| 9 |
+
from selenium import webdriver
|
| 10 |
+
from selenium.webdriver.chrome.options import Options
|
| 11 |
+
from selenium.webdriver.common.by import By
|
| 12 |
+
from xvfbwrapper import Xvfb
|
| 13 |
+
from threading import Lock, Event
|
| 14 |
|
| 15 |
+
# Create a logger
|
| 16 |
+
logger = logging.getLogger(__name__)
|
| 17 |
|
| 18 |
+
# Set up the Flask application
|
| 19 |
app = Flask(__name__)
|
| 20 |
+
|
| 21 |
+
# Create a FormFiller instance
|
| 22 |
form_filler = FormFiller()
|
| 23 |
|
| 24 |
+
# Define the routes for the Flask application
|
| 25 |
@app.route('/')
|
| 26 |
def index():
|
| 27 |
return render_template('index.html')
|
|
|
|
| 32 |
iterations = int(request.json['iterations'])
|
| 33 |
|
| 34 |
def run_form_filler():
|
| 35 |
+
try:
|
| 36 |
+
form_filler.fill_form_in_parallel(url, iterations)
|
| 37 |
+
except Exception as e:
|
| 38 |
+
logger.error(f"Error occurred: {e}")
|
| 39 |
|
| 40 |
form_filler.total_iterations = iterations
|
| 41 |
form_filler.iterations_left = iterations
|
|
|
|
| 74 |
"environment_status": list(form_filler.environment_status)
|
| 75 |
})
|
| 76 |
|
|
|
|
| 77 |
if __name__ == '__main__':
|
| 78 |
app.run()
|