-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
executable file
·48 lines (41 loc) · 1.29 KB
/
run.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
from flask import Flask, render_template, json, request
# from flaskext.mysql import MySQL
# mysql = MySQL()
app = Flask(__name__, static_url_path='/public', static_folder='public')
# MySQL configurations
# app.config['MYSQL_DATABASE_USER'] = ''
# app.config['MYSQL_DATABASE_PASSWORD'] = ''
# app.config['MYSQL_DATABASE_DB'] = ''
# app.config['MYSQL_DATABASE_HOST'] = ''
# mysql.init_app(app)
def byteify(input):
if isinstance(input, dict):
return {byteify(key):byteify(value) for key,value in input.iteritems()}
elif isinstance(input, list):
return [byteify(element) for element in input]
elif isinstance(input, unicode):
return input.encode('utf-8')
else:
return input
@app.route('/', defaults={'path': ''})
# @app.route('/<path:path>')
def template_test(path):
data = None
# if path != '':
# print path
# try:
# cursor = mysql.get_db().cursor()
# query = "SELECT `map` FROM `maps` WHERE `key` = '" + path + "'"
# print query
# cursor.execute(query)
# string = cursor.fetchone()[0]
# print string
# data = byteify(json.loads(string))
# print data
# except Exception as e:
# print e
# finally:
# cursor.close()
return render_template('template.html', data = data if data else '')
if __name__ == '__main__':
app.run(debug=True)