This repository has been archived by the owner on Feb 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
77 lines (59 loc) · 1.85 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from classes import *
import code as code
import info as info
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
import threading
import os
#from werkzeug.contrib.fixers import ProxyFix
#app.wsgi_app = ProxyFix(app.wsgi_app)
class Thread (threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
code.main()
self.exit()
app = Flask(__name__)
@app.route('/')
def homepage():
return render_template('step1.html')
@app.route('/step1/', methods=["GET","POST"])
def step1():
return render_template('step1.html')
@app.route('/home/', methods=["GET","POST"])
def home():
return render_template('step1.html')
@app.route('/loading/', methods=["GET","POST"])
def loading():
try:
if request.method == "POST":
b,w,s = int(request.form['boardsize']),int(request.form['wordno']),int(request.form['sec'])
code.size = b
code.wordnum = w
code.sec = s
thread_main = Thread()
thread_main.start()
return render_template('loading.html')
except Exception as e:
print e.message
return e.message
@app.route('/_info_/')
def display_info():
try:
return info.info_string
except Exception as e:
return e.message
@app.route('/loading/_info_/')
def display_info_2():
try:
return info.info_string
except Exception as e:
return e.message
@app.route('/_output_/', methods=["GET","POST"])
def output():
return render_template('output.html',length=(len(info.grid[0]) * 15), grid = info.grid, gridnum = info.gridnum , wordlist = info.wordlist)
@app.route('/loading/_output_/', methods=["GET","POST"])
def output_2():
return render_template('output.html',length=(len(info.grid[0]) * 15), grid = info.grid, gridnum = info.gridnum , wordlist = info.wordlist)
if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000))
app.run(threaded=True,port=port)