-
Notifications
You must be signed in to change notification settings - Fork 3
/
flaskRun.py
45 lines (37 loc) · 1.1 KB
/
flaskRun.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import flask
from flask import Flask,request
import selenium
from selenium import webdriver
import backend
app = Flask(__name__)
ANKUR_WEBDRIVER = "/Users/ankuringale/Desktop/chromedriver"
MIHIR_WEBDRIVER = "/home/mihir/bin/chromedriver"
sample_object = {
'link': '#',
'name': 'Medicine',
'price': 0
}
sample_data = [{
'apollo': sample_object,
'pharmeasy': sample_object,
'netmeds': sample_object,
'onemg': sample_object
}] * 5
@app.route('/')
def index(data = None):
return flask.render_template('index.html', data=data)
@app.route('/handle_data', methods = ['POST'])
def handle_data():
data, src = backend.compileData([request.form['type'], request.form['name']])
searched_text = request.form['name']
return flask.render_template('index.html', data=data, src=src, search=searched_text)
def getDriver():
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--incognito')
options.add_argument('--headless')
driver = webdriver.Chrome(MIHIR_WEBDRIVER, chrome_options=options)
return driver
if __name__ == '__main__':
app.debug=True
app.run()