An ebook/comic library service and web client
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.

42 lines
1.0 KiB

  1. import os
  2. from flask import Flask
  3. from flask_migrate import Migrate
  4. from flask_sqlalchemy import SQLAlchemy
  5. db: SQLAlchemy = SQLAlchemy()
  6. from atheneum.api import api_blueprint
  7. def create_app(test_config=None):
  8. app = Flask(__name__, instance_relative_config=True)
  9. app.config.from_mapping(
  10. SECRET_KEY='dev',
  11. SQLALCHEMY_DATABASE_URI='sqlite:////tmp/atheneum-test.db'
  12. # SQLALCHEMY_DATABASE_URI=os.path.join(app.instance_path, 'atheneum.db')
  13. )
  14. if test_config is None:
  15. app.config.from_object('atheneum.default_settings')
  16. app.config.from_pyfile('config.py', silent=True)
  17. if os.getenv('ATHENEUM_SERVER_SETTINGS', None):
  18. app.config.from_envvar('ATHENEUM_SERVER_SETTINGS')
  19. else:
  20. app.config.from_pyfile(test_config)
  21. try:
  22. os.makedirs(app.instance_path)
  23. except OSError:
  24. pass
  25. app.register_blueprint(api_blueprint)
  26. db.init_app(app)
  27. migrate = Migrate(app, db)
  28. return app
  29. if __name__ == "__main__":
  30. app = create_app()
  31. app.run()