You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

4 years ago
  1. from flask import Flask
  2. def create_app():
  3. app = Flask(__name__)
  4. app.config.from_object('acks.default_settings')
  5. app.config.from_envvar('FLASK_SETTINGS_FILE')
  6. # Prep the database
  7. from acks.models import db
  8. app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///../data/acks.db'
  9. app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
  10. db.init_app(app)
  11. # Prep basic auth
  12. from acks.views import basic_auth
  13. basic_auth.init_app(app)
  14. # Load our views
  15. from acks.views import default_views
  16. app.register_blueprint(default_views)
  17. from acks.npc.views import npc_views
  18. app.register_blueprint(npc_views)
  19. from acks.quest.views import quest_views
  20. app.register_blueprint(quest_views)
  21. # Load our CLI commands
  22. from acks.commands import default_cli
  23. app.cli.add_command(default_cli)
  24. from acks.npc.commands import npc_cli
  25. app.cli.add_command(npc_cli)
  26. # Load the Admin views
  27. from flask_admin import Admin
  28. from flask_admin.contrib.sqla import ModelView
  29. admin = Admin(app, name='acks', template_mode='bootstrap3')
  30. from acks.npc.models import admin_models as npc_admin_models
  31. for mdl in npc_admin_models:
  32. admin.add_view(ModelView(mdl, db.session))
  33. # Initialize API and load resources
  34. from flask_potion import Api, ModelResource
  35. api = Api(app, prefix='/api')
  36. # from acks.api import api
  37. # api.init_app(app)
  38. from acks.npc.api import resources as npc_resources
  39. for resource in npc_resources:
  40. api.add_resource(resource)
  41. return app