diff --git a/main.py b/main.py index 6613ec7..e9a76a7 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,14 @@ -from flask import Flask, render_template, send_from_directory +from flask import Flask, render_template, send_from_directory, redirect, request from markdown import markdown from prefix import PrefixMiddleware from dotenv import load_dotenv -import os +import os, subprocess load_dotenv() prefix = os.environ.get('URL_PREFIX', '') port = os.environ.get('PORT', '3000') debug = os.environ.get('DEBUG', 'False') +update_script = os.environ.get('UPDATE', 'update.sh' ) def list_files(folder, remove_ext=False): @@ -50,4 +51,10 @@ def list(slug): def send_img(file): return send_from_directory(app.root_path + '/img/', file, conditional=True) +@app.route('/api/update', methods=['GET', 'POST']) +def update(): + if request.method == 'POST': + subprocess.run(update_script, shell=True) + return 'Updated!' + app.run(port=port, debug=debug) \ No newline at end of file diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..28c6ef6 --- /dev/null +++ b/update.sh @@ -0,0 +1,2 @@ +git stash +git pull \ No newline at end of file