-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
69 lines (51 loc) · 1.75 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
import os
from flask import Flask, render_template, send_from_directory, Response, url_for, request
import json
#----------------------------------------
# initialization
#----------------------------------------
app = Flask(__name__)
app.config.update(
DEBUG = True,
)
app.config["SECRET_KEY"] = 'T\x9cs;\x8b\xce-@\xac\xbb\xc9m\xeb\xe8\x1f\x85]\xd2M\xf5\xae$I\x9a'
### marker for flask app generator - keep this line
#----------------------------------------
# controllers
#----------------------------------------
# @app.route('/favicon.ico')
# def favicon():
# return send_from_directory(os.path.join(app.root_path, 'static'), 'ico/favicon.ico')
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
@app.route("/")
def index():
return render_template('index.html')
#----------------------------------------
# handlers
#----------------------------------------
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'), 'ico/favicon.ico')
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
#----------------------------------------
# database
#----------------------------------------
from mongoengine import connect
from flask.ext.mongoengine import MongoEngine
DB_NAME = 'jrflask'
DB_USERNAME = 'jrflaskadmin'
DB_PASSWORD = 'jrflask12345'
DB_HOST_ADDRESS = 'ds031278.mongolab.com:31278/jrflask'
app.config["MONGODB_DB"] = DB_NAME
connect(DB_NAME, host='mongodb://' + DB_USERNAME + ':' + DB_PASSWORD + '@' + DB_HOST_ADDRESS)
db = MongoEngine(app)
#----------------------------------------
# launch
#----------------------------------------
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port)