-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.py
30 lines (29 loc) · 962 Bytes
/
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
"""Run the server in either production or development."""
from app import app, db, models
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from passlib.hash import sha256_crypt
if app.config['ENV'] == 'PROD':
db.create_all()
email = app.config['ADMIN_EMAIL'].lower()
pw = app.config['ADMIN_PW']
hash = sha256_crypt.encrypt(pw)
user = models.User(email, hash)
db.session.add(user)
db.session.commit()
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(9000)
print("Running production on 9000")
IOLoop.instance().start()
elif app.config['ENV'] == 'DEV':
db.drop_all()
db.create_all()
email = app.config['ADMIN_EMAIL']
pw = app.config['ADMIN_PW']
hash = sha256_crypt.encrypt(pw)
user = models.User(email, hash)
db.session.add(user)
db.session.commit()
print("Running development")
app.run(debug=True)