|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
import os |
|
|
|
|
from flask import Flask, send_from_directory, render_template, request,\ |
|
|
|
|
redirect |
|
|
|
|
from flask import Flask, send_from_directory, render_template, request |
|
|
|
|
from flask_httpauth import HTTPDigestAuth |
|
|
|
|
import ciclostile |
|
|
|
|
|
|
|
|
|
working_dir = os.getcwd() |
|
|
|
@ -12,6 +12,19 @@ target_path, template_path, markdown_path = [ |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
app.config['SECRET_KEY'] = 'secret key here' |
|
|
|
|
auth = HTTPDigestAuth() |
|
|
|
|
|
|
|
|
|
users = { |
|
|
|
|
'admin': 'password', |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@auth.get_password |
|
|
|
|
def get_pw(username): |
|
|
|
|
if username in users: |
|
|
|
|
return users.get(username) |
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/assets/<path:path>') |
|
|
|
@ -27,12 +40,14 @@ def page(page_name): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/<string:page_name>/edit') |
|
|
|
|
@auth.login_required |
|
|
|
|
def edit(page_name): |
|
|
|
|
md_text = ciclostile.read_markdown(page_name, markdown_path) |
|
|
|
|
return render_template('edit.html', **locals()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/edit', methods=['POST']) |
|
|
|
|
@auth.login_required |
|
|
|
|
def edit_actions(): |
|
|
|
|
page_name = request.form['page_name'] |
|
|
|
|
md_text = request.form['md_text'] |
|
|
|
|