-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
36 lines (29 loc) · 871 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from flask import Flask, render_template, request, redirect
import model
app = Flask(__name__)
@app.route("/")
def index():
## print the guestbook
return render_template("index.html", entries=model.get_entries())
@app.route("/add")
def addentry():
## add a guestbook entry
return render_template("addentry.html")
@app.route("/postentry", methods=["POST"])
def postentry():
name = request.form["name"]
message = request.form["message"]
model.add_entry(name, message)
return redirect("/")
@app.route("/admin")
def admin():
return render_template("admin.html", entries=model.get_entries())
@app.route("/delete", methods=["POST"])
def delete():
#delete entry from entries list
id = request.form["id"]
model.delete_entry(id)
return redirect('/admin')
if __name__=="__main__":
model.init()
app.run(debug=True)