50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
import inspect
|
|
import json
|
|
|
|
from flask import Flask, render_template
|
|
from flask_login import LoginManager
|
|
|
|
from . import (
|
|
auth,
|
|
db,
|
|
entry,
|
|
inventory,
|
|
location,
|
|
template_utils
|
|
)
|
|
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
app.config.from_file("default-config.json", load=json.load)
|
|
# You don't need a config.json. If you don't provide one, default-config.json
|
|
# is used.
|
|
app.config.from_file("config.json", load=json.load, silent=True)
|
|
|
|
db.init_app(app)
|
|
|
|
login_manager = LoginManager()
|
|
login_manager.login_view = 'auth.login'
|
|
login_manager.init_app(app)
|
|
|
|
@login_manager.user_loader
|
|
def load_user(user_id):
|
|
# since the user_id is just the primary key of our user table, use it in the query for the user
|
|
return auth.User()
|
|
|
|
@app.context_processor
|
|
def utility_processor():
|
|
return dict(inspect.getmembers(template_utils, inspect.isfunction))
|
|
|
|
app.register_blueprint(location.bp)
|
|
app.register_blueprint(inventory.bp)
|
|
app.register_blueprint(entry.bp)
|
|
app.register_blueprint(auth.auth)
|
|
@app.route("/")
|
|
def index():
|
|
return render_template("index.html")
|
|
|
|
print("Jon started. Token: %s" % auth.ACCESS_TOKEN)
|
|
|
|
return app
|