-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
37 lines (24 loc) · 808 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
37
from contacts_model import Contact
from flask import Flask, render_template, request
Contact.load_db()
app: Flask = Flask(__name__)
app.secret_key = b"it is over"
@app.route("/")
def index() -> str:
return render_template("index.html")
@app.route("/contacts-partial")
def contacts_partial() -> str:
return render_template("partial.html")
@app.route("/contacts-demo")
def contacts_demo() -> str:
return "You got contacts!"
@app.route("/contacts", methods=["GET", "POST"])
def contacts() -> str:
search: str | None = request.form.get("q")
if search is not None:
contacts_set: list = Contact.search(search)
else:
contacts_set = Contact.all()
return render_template("partial.html", contacts=contacts_set)
if __name__ == "__main__":
app.run(port=5018)