lets try logging
This commit is contained in:
23
code/app.py
23
code/app.py
@@ -15,7 +15,7 @@ from flask import (
|
|||||||
)
|
)
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from revprox import ReverseProxied
|
from revprox import ReverseProxied
|
||||||
from utils.misc import random_token, hash_password, verify_password
|
from utils.misc import random_token, hash_password, verify_password,file_date_human
|
||||||
from utils.files import (
|
from utils.files import (
|
||||||
db_store_file,
|
db_store_file,
|
||||||
file_details,
|
file_details,
|
||||||
@@ -28,8 +28,14 @@ from utils.files import (
|
|||||||
db_delete_file,
|
db_delete_file,
|
||||||
db_maintenance,
|
db_maintenance,
|
||||||
)
|
)
|
||||||
|
import logging
|
||||||
|
|
||||||
__VERSION__ = "20230820.0"
|
logging.basicConfig(
|
||||||
|
level=logging.INFO,
|
||||||
|
format=f"[%(asctime)s] [%(levelname)s] %(message)s",
|
||||||
|
)
|
||||||
|
|
||||||
|
__VERSION__ = "20230821.0"
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(__name__)
|
app.config.from_object(__name__)
|
||||||
app.config.from_prefixed_env()
|
app.config.from_prefixed_env()
|
||||||
@@ -38,6 +44,16 @@ app.secret_key = app.config["APP_SECRET_KEY"]
|
|||||||
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
app.wsgi_app = ReverseProxied(app.wsgi_app)
|
||||||
|
|
||||||
|
|
||||||
|
@app.before_request
|
||||||
|
def log_request_info():
|
||||||
|
pass
|
||||||
|
|
||||||
|
@app.after_request
|
||||||
|
def log_the_status_code(response):
|
||||||
|
ip = request.environ.get("HTTP_X_FORWARDED_FOR", request.remote_addr)
|
||||||
|
app.logger.info(f'{request.method}:{response.status_code} {request.url} {ip}')
|
||||||
|
return response
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
"""Returns Nothing"""
|
"""Returns Nothing"""
|
||||||
@@ -121,6 +137,9 @@ def upload():
|
|||||||
|
|
||||||
db_store_file(token, safe_filename, expires, max_dl, password)
|
db_store_file(token, safe_filename, expires, max_dl, password)
|
||||||
download_url = file_full_url(token, safe_filename)
|
download_url = file_full_url(token, safe_filename)
|
||||||
|
app.logger.info(
|
||||||
|
f'Upload: {download_url} MaxDL:{max_dl} Exp:{file_date_human(expires)}'
|
||||||
|
)
|
||||||
return "File uploaded\n%s\n" % (download_url,), 200
|
return "File uploaded\n%s\n" % (download_url,), 200
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,4 +19,10 @@ set -eu
|
|||||||
. /opt/venv/bin/activate
|
. /opt/venv/bin/activate
|
||||||
sh ./init_db.sh "$FLASK_DB"
|
sh ./init_db.sh "$FLASK_DB"
|
||||||
|
|
||||||
exec "$SERVER" -w $WORKERS --timeout $TIMEOUT 'app:app' --pid="$PID" -b 0.0.0.0:5000
|
exec "$SERVER" \
|
||||||
|
-w $WORKERS \
|
||||||
|
--timeout $TIMEOUT \
|
||||||
|
--pid="$PID" \
|
||||||
|
-b 0.0.0.0:5000 \
|
||||||
|
'app:app' \
|
||||||
|
2>&1 | tee -a /data/flees.log
|
||||||
|
|||||||
Reference in New Issue
Block a user