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.

49 lines
1.4 KiB

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