-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
38 lines (28 loc) · 999 Bytes
/
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
import os
from flask import Flask
from flask_restful import Api
from resources.client import Client
from resources.form import MessageForm, UserForm
from resources.home import Home
from resources.matrix import MatrixAPI
from resources.thinking_of import ThinkingOf
app = Flask(__name__, static_folder='static', static_url_path='/static')
app.config['DEBUG'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
'DATABASE_URL', 'sqlite:///data.db')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
api = Api(app)
api.add_resource(Home, '/')
api.add_resource(MessageForm, '/send')
api.add_resource(UserForm, '/user')
api.add_resource(Client, '/data/<string:_to>')
api.add_resource(ThinkingOf, '/thinking_of/<string:_to>')
api.add_resource(MatrixAPI, '/matrix')
if __name__ == '__main__':
from db import db
db.init_app(app)
if app.config['DEBUG']:
@app.before_first_request
def create_tables():
db.create_all()
app.run(port=5000)