master
km0 2 years ago
parent f84556c1ef
commit 19199dffa9

@ -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 markdown import markdown
from prefix import PrefixMiddleware from prefix import PrefixMiddleware
from dotenv import load_dotenv from dotenv import load_dotenv
import os import os, subprocess
load_dotenv() load_dotenv()
prefix = os.environ.get('URL_PREFIX', '') prefix = os.environ.get('URL_PREFIX', '')
port = os.environ.get('PORT', '3000') port = os.environ.get('PORT', '3000')
debug = os.environ.get('DEBUG', 'False') debug = os.environ.get('DEBUG', 'False')
update_script = os.environ.get('UPDATE', 'update.sh' )
def list_files(folder, remove_ext=False): def list_files(folder, remove_ext=False):
@ -50,4 +51,10 @@ def list(slug):
def send_img(file): def send_img(file):
return send_from_directory(app.root_path + '/img/', file, conditional=True) 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) app.run(port=port, debug=debug)

@ -0,0 +1,2 @@
git stash
git pull
Loading…
Cancel
Save