-
Notifications
You must be signed in to change notification settings - Fork 1
/
actorHunt.py
46 lines (35 loc) · 1.18 KB
/
actorHunt.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
from flask import (
Flask,
json,
render_template,
request,
make_response,
)
import writingInfo
import json
# Defining a FLASK web app
app = Flask(__name__)
# Route to the main page and rendering main page html
@app.route("/", methods=["POST", "GET"])
def mainPage():
return render_template("index.html", content="")
@app.route("/search", methods=["POST", "GET"])
def getJson():
if request.method == "POST":
req = request.get_json() # getting the request data from client
actorName, actorBD, actorJobs, actorPhotoPath, _ = writingInfo.DoIt(req["name"])
res = make_response(
json.dumps( # Converting the data received into an JSON Format
{
"name": actorName,
"job": actorJobs,
"dob": actorBD[5:],
"pic": actorPhotoPath,
}
),
200,
)
return res # returning the JSON data to client with STATUS 200 OK
return "get request received, something wrong"
if __name__ == "__main__":
app.run(debug=True) # debug is set True to refresh the server whenever the changes are made