Files
autoreply-editor/autoreply_editor/main.py

26 lines
728 B
Python
Raw Normal View History

2021-05-19 09:30:01 +02:00
"""Provide basic settings and views"""
from flask import request, render_template, redirect
2021-05-19 09:17:41 +02:00
from flask_basicauth import BasicAuth
2021-05-19 09:30:01 +02:00
from autoreply_editor import app
2021-05-19 09:17:41 +02:00
basic_auth = BasicAuth(app)
2021-05-18 19:15:49 +02:00
@app.route("/")
def index():
with open(app.config.get("MESSAGE_FILE"), "r") as f:
2021-05-18 19:32:59 +02:00
message = f.read()
2021-05-18 19:15:49 +02:00
2021-05-18 19:32:59 +02:00
return render_template("index.html", message=message)
@app.route('/', methods=['POST'])
def index_post():
2021-05-18 19:53:31 +02:00
input_message = request.form['message']
2021-05-18 19:32:59 +02:00
if request.method == 'POST':
with open(app.config.get("MESSAGE_FILE"), 'w') as f:
f.write(str(input_message))
2021-05-19 10:23:47 +02:00
result = "Success: The autoreply message has been updated!"
return render_template("result.html", result=result)