commit
This commit is contained in:
34
app/__init__.py
Normal file
34
app/__init__.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from flask import Flask, request, render_template
|
||||
from .config import Config
|
||||
from .api import api_bp
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
|
||||
app.register_blueprint(api_bp, url_prefix='/api')
|
||||
|
||||
@app.route('/favicon.ico')
|
||||
def favicon():
|
||||
return '', 204
|
||||
|
||||
@app.after_request
|
||||
def add_cache_headers(response):
|
||||
if request.path.startswith('/static/'):
|
||||
max_age = app.config['STATIC_CACHE_MAX_AGE']
|
||||
response.headers['Cache-Control'] = f'public, max-age={max_age}'
|
||||
return response
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
template_vars = {
|
||||
'APP_TITLE': app.config['APP_TITLE'],
|
||||
'APP_FOOTER': app.config['APP_FOOTER']
|
||||
}
|
||||
return render_template('main.html', config=template_vars)
|
||||
|
||||
@app.route('/api/health')
|
||||
def health():
|
||||
return {'status': 'OK'}
|
||||
|
||||
return app
|
||||
Reference in New Issue
Block a user