2018-04-26 12:12:20 +00:00
|
|
|
import atexit
|
2018-04-14 11:44:47 +00:00
|
|
|
from flask import Flask
|
2018-04-26 12:51:37 +00:00
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
2018-04-26 12:12:20 +00:00
|
|
|
from app.mod_devices import setup_mqtt, tear_down_mqtt
|
2018-04-25 13:51:28 +00:00
|
|
|
|
|
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
|
|
app.config.from_object('config')
|
|
|
|
app.config.from_pyfile('config.py')
|
2018-04-26 12:51:37 +00:00
|
|
|
db = SQLAlchemy(app)
|
2018-04-26 12:12:20 +00:00
|
|
|
|
2018-04-26 13:03:38 +00:00
|
|
|
|
2018-04-26 12:12:20 +00:00
|
|
|
def on_stop():
|
|
|
|
print('Application stopping')
|
|
|
|
tear_down_mqtt()
|
|
|
|
|
2018-04-26 13:03:38 +00:00
|
|
|
|
2018-04-26 12:12:20 +00:00
|
|
|
setup_mqtt(app)
|
|
|
|
atexit.register(on_stop)
|
2018-04-14 11:44:47 +00:00
|
|
|
|
2018-04-26 13:03:38 +00:00
|
|
|
|
2018-04-14 11:44:47 +00:00
|
|
|
@app.route("/")
|
|
|
|
def hello():
|
|
|
|
return "Hello World!"
|