summaryrefslogtreecommitdiff
path: root/app/main.py
blob: 9dc9b5b1c624a6633f2b2f634a89e9170895d3ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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")