simple form to update message text
This commit is contained in:
@@ -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("/")
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
<p>
|
||||
Hello! {{ content }}
|
||||
</p>
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Autoreply Editor</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form action="" method="POST">
|
||||
<textarea name="message" cols="70" rows="10">{{ message }}</textarea>
|
||||
<br />
|
||||
<input type="submit" value="Update">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user