dankventskalender migrate to flask
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

48 行
1.1KB

  1. import os
  2. from os.path import join, dirname, realpath
  3. from flask import Flask
  4. UPLOAD_FOLDER = join(dirname(realpath(__file__)), 'media/memes')
  5. def create_app(test_config=None):
  6. # create and configure the app
  7. app = Flask(__name__, instance_relative_config=True)
  8. app.config.from_mapping(
  9. SECRET_KEY='dev',
  10. DATABASE=os.path.join(app.instance_path, 'calender.sqlite'),
  11. )
  12. app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
  13. if test_config is None:
  14. # load the instance config, if it exists, when not testing
  15. app.config.from_pyfile('config.py', silent=True)
  16. else:
  17. # load the test config if passed in
  18. app.config.from_mapping(test_config)
  19. # ensure the instance folder exists
  20. try:
  21. os.makedirs(app.instance_path)
  22. except OSError:
  23. pass
  24. # a simple page that says hello
  25. @app.route('/hello')
  26. def hello():
  27. return 'Hello, World!'
  28. from . import db
  29. db.init_app(app)
  30. from . import auth
  31. app.register_blueprint(auth.bp)
  32. from . import calender
  33. app.register_blueprint(calender.bp)
  34. app.add_url_rule('/', endpoint='index')
  35. return app