-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflaskify.py
More file actions
18 lines (13 loc) · 1.07 KB
/
flaskify.py
File metadata and controls
18 lines (13 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import flask # do `pip3 install flask` if it gives you trouble
from ShowsData import Shows
from AlbumData import Album
app = flask.Flask(__name__) # define the flask app like this
app.config["DEBUG"] = True # debug will print useful stuff out
@app.route('/Shows/<year>', methods=['GET']) # this is called a decorator. it has info on the name of the endpoint and supported http method.
def ShowsWrapper(year): # this will be your wrapper function. each path var (thing in square brackets) is an input to this.
return str(Shows(year))
@app.route('/Album/<title>', methods=['GET']) # this is called a decorator. it has info on the name of the endpoint and supported http method.
def AlbumWrapper(title): # this will be your wrapper function. each path var (thing in square brackets) is an input to this.
return str(Album(title))
app.run() # actually starts the flask server
# to make requests, try `curl 127.0.0.1:5000/endpoint1/2022/Remi` (replace it with the IP address and port that it gives you when you start it up)