-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (33 loc) · 1.29 KB
/
main.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
import random, string
from flask import Flask, render_template, request
from scrap import loop_for_company
from config import HOUR_DELAY
app = Flask( # Create a flask app
__name__,
template_folder='templates', # Name of html file folder
static_folder='static' # Name of directory for static files
)
ok_chars = string.ascii_letters + string.digits
@app.route('/') # What happens when the user visits the site
def base_page():
random_num = random.randint(1, 100000) # Sets the random number
return render_template(
'base.html', # Template file path, starting from the templates folder.
random_number=random_num # Sets the variable random_number in the template
)
@app.route('/2')
def page_2():
rand_ammnt = random.randint(10, 100)
random_str = ''.join(random.choice(ok_chars) for a in range(rand_ammnt))
return render_template('site_2.html', random_str=random_str)
@app.route('/company/<name>')
def get_product(name):
hours = request.args.get('hours', 24)
loop_for_company(name)
return "success"
if __name__ == "__main__": # Makes sure this is the main process
# loop_for_company("datacm")
app.run( # Starts the site
host='0.0.0.0', # Establishes the host, required for repl to detect the site
port=random.randint(2000, 9000) # Randomly select the port the machine hosts on.
)