-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
34 lines (25 loc) · 888 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
31
32
33
34
import os
from dotenv import load_dotenv
from hook import create_app, socketio
from hook.models import Channel, Dm, Message, User, db
app = create_app(debug=False)
# load configurations from .env file
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path)
@app.shell_context_processor
def make_shell_context():
return dict(db=db, User=User, Channel=Channel, Message=Message, Dm=Dm)
@app.cli.command()
def create_db():
"""Creates all the required databases for app to run"""
db.create_all()
print("DB CREATED...")
@app.cli.command()
def test():
"""Run all tests for the application"""
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)
if __name__ == '__main__':
socketio.run(app)