diff options
Diffstat (limited to 'app/main.py')
-rw-r--r-- | app/main.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..9dc9b5b --- /dev/null +++ b/app/main.py @@ -0,0 +1,18 @@ +from flask import * +from tinydb import TinyDB + +app = Flask(__name__) + +@app.route("/") +def home(): + posts = get_db().all() + return render_template("home.html", posts = posts) + +@app.route("/message", methods=["POST"]) +def create_message(): + form = request.form + get_db().insert({ "name": form["name"], "email": form["email"], "message": form["message"]}) + return redirect("/") + +def get_db(): + return TinyDB("db.json").table("messages") |