-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
51 lines (34 loc) · 1.16 KB
/
app.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
46
47
48
49
50
51
from flask import Flask, render_template, request, redirect
import random
from flask.helpers import url_for
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def home():
global a
with open("Index.txt") as f:
a = list(map(lambda x: x.strip("\n"), f.readlines()))
if request.form.get('randomGet'):
return redirect(url_for('index'))
return render_template("main.html")
@app.route('/index', methods=['GET', 'POST'])
def index():
if request.form.get("end"):
return redirect(url_for('home'))
if request.form.get("main"):
return redirect(url_for('home'))
if request.form.get("submit"):
if len(a) > 1:
index = random.choice(a)
a.remove(index)
return render_template('random.html', indexNo=index)
elif len(a) == 1:
index = random.choice(a)
a.remove(index)
return render_template("end.html", indexNo=index)
else:
return redirect(url_for('home'))
index = random.choice(a)
a.remove(index)
return render_template('random.html', indexNo=index)
if __name__ == "__main__":
app.run(debug=True)