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

24 lines
623 B
Python

"""Provide basic settings and views"""
from flask import request, render_template, redirect
from flask_basicauth import BasicAuth
from autoreply_editor import app
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("/")