diff --git a/autoreply_editor/main.py b/autoreply_editor/main.py index 73c3598..20a5e48 100644 --- a/autoreply_editor/main.py +++ b/autoreply_editor/main.py @@ -1,9 +1,17 @@ from autoreply_editor import app -from flask import render_template +from flask import Flask, request, render_template, redirect @app.route("/") def index(): with open(app.config.get("MESSAGE_FILE"), "r") as f: - content = f.read() + message = f.read() - return render_template("index.html", content=content) + return render_template("index.html", message=message) + +@app.route('/', methods=['POST']) +def index_post(): + input_message = request.form['message'] + '\n' + if request.method == 'POST': + with open(app.config.get("MESSAGE_FILE"), 'w') as f: + f.write(str(input_message)) + return redirect("/") diff --git a/autoreply_editor/templates/index.html b/autoreply_editor/templates/index.html index f29ea2d..58e6f30 100644 --- a/autoreply_editor/templates/index.html +++ b/autoreply_editor/templates/index.html @@ -1,3 +1,13 @@ -
- Hello! {{ content }} -
+ + +