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.

57 lines
1.6 KiB

3 years ago
3 years ago
3 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, player_auth
  13. basic_auth.init_app(app)
  14. player_auth.init_app(app)
  15. # Load our views
  16. from acks.views import default_views
  17. app.register_blueprint(default_views)
  18. from acks.npc.views import npc_views
  19. app.register_blueprint(npc_views)
  20. from acks.quest.views import quest_views
  21. app.register_blueprint(quest_views)
  22. # Load our CLI commands
  23. from acks.commands import default_cli
  24. app.cli.add_command(default_cli)
  25. from acks.npc.commands import npc_cli
  26. app.cli.add_command(npc_cli)
  27. # Load the Admin views
  28. from flask_admin import Admin
  29. from flask_admin.contrib.sqla import ModelView
  30. admin = Admin(app, name='acks', template_mode='bootstrap3')
  31. from acks.npc.models import admin_models as npc_admin_models
  32. for mdl in npc_admin_models:
  33. admin.add_view(ModelView(mdl, db.session))
  34. # Initialize API and load resources
  35. from flask_potion import Api, ModelResource
  36. api = Api(app, prefix='/api')
  37. # from acks.api import api
  38. # api.init_app(app)
  39. from acks.npc.api import resources as npc_resources
  40. for resource in npc_resources:
  41. api.add_resource(resource)
  42. return app