Files
autoreply-editor/autoreply_editor/main.py
2021-05-19 09:17:41 +02:00

22 lines
590 B
Python

from autoreply_editor import app
from flask import Flask, request, render_template, redirect
from flask_basicauth import BasicAuth
basic_auth = BasicAuth(app)
@app.route("/")
def index():
with open(app.config.get("MESSAGE_FILE"), "r") as f:
message = f.read()
return render_template("index.html", message=message)
@app.route('/', methods=['POST'])
def index_post():
input_message = request.form['message']
if request.method == 'POST':
with open(app.config.get("MESSAGE_FILE"), 'w') as f:
f.write(str(input_message))
return redirect("/")