healthcheck w docker-compose
This commit is contained in:
10
app.py
10
app.py
@@ -35,6 +35,7 @@ UPLOAD_FOLDER = app.config.get('UPLOAD_FOLDER', 'uploads')
|
||||
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'webp'}
|
||||
AUTHORIZED_COOKIE_VALUE = app.config.get('AUTHORIZED_COOKIE_VALUE', '80d31cdfe63539c9')
|
||||
AUTH_COOKIE_MAX_AGE = app.config.get('AUTH_COOKIE_MAX_AGE', 86400)
|
||||
HEALTHCHECK_TOKEN = app.config.get('HEALTHCHECK_TOKEN', 'alamapsaikota1234')
|
||||
|
||||
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
||||
|
||||
@@ -1201,6 +1202,15 @@ def demote_user(user_id):
|
||||
flash(f'Użytkownik {user.username} został zdegradowany.', 'success')
|
||||
return redirect(url_for('list_users'))
|
||||
|
||||
@app.route('/healthcheck')
|
||||
def healthcheck():
|
||||
header_token = request.headers.get("X-Internal-Check")
|
||||
correct_token = current_app.config.get("HEALTHCHECK_TOKEN")
|
||||
|
||||
if header_token != correct_token:
|
||||
abort(403)
|
||||
return 'OK', 200
|
||||
|
||||
# =========================================================================================
|
||||
# SOCKET.IO
|
||||
# =========================================================================================
|
||||
|
Reference in New Issue
Block a user