-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.py
60 lines (44 loc) · 1.51 KB
/
server.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
Main module of the server file
"""
# 3rd party moudles
from flask import render_template, make_response
# Local modules
import config
# Get the application instance
connex_app = config.connex_app
# Read the swagger.yml file to configure the endpoints
connex_app.add_api("api.yml")
# Create a URL route in our application for "/"
@connex_app.route("/")
def home():
"""
This function just responds to the browser URL
localhost:5000/
:return: the rendered template "home.html"
"""
return render_template("home.html")
# Create a URL route in our application for "/people"
@connex_app.route("/people")
@connex_app.route("/people/<int:person_id>")
def people(person_id=""):
"""
This function just responds to the browser URL
localhost:5000/people
:return: the rendered template "people.html"
"""
return render_template("people.html", person_id=person_id)
# Create a URL route to the notes page
@connex_app.route("/people/<int:person_id>")
@connex_app.route("/people/<int:person_id>/notes", methods=["GET", "POST"])
@connex_app.route("/people/<int:person_id>/notes/<int:note_id>")
def notes(person_id, note_id=""):
"""
This function responds to the browser URL
localhost:5000/notes/<person_id>
:param person_id: Id of the person to show notes for
:return: the rendered template "notes.html"
"""
return render_template("notes.html", person_id=person_id, note_id=note_id)
if __name__ == "__main__":
connex_app.run(debug=True)