-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
58 lines (47 loc) · 1.97 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from session import generateCredentials
from flask import Flask, jsonify
import requests
app = Flask(__name__)
devId = ""
sessionId = ""
def getSession():
return generateCredentials(devId, sessionId, "createsession").generate_session()
# return the signature and timestamp
def getSignature(method):
return generateCredentials(devId, sessionId, method).generate_signature()
def getResponse(method, session, signature, timestamp, player):
return requests.get(f"http://api.paladins.com/paladinsapi.svc/{method}json/\
{devId}/{signature}/{session}/{timestamp}/{player}")
@app.route("/getplayer/<player>")
def getPlayer(player):
session = getSession()
signature, timestamp = getSignature("getplayer")
response = getResponse("getplayer", session, signature, timestamp, player)
return jsonify(response.json())
@app.route("/getchampions/<player>")
def getChampion(player):
session = getSession()
signature, timestamp = getSignature("getchampionranks")
response = getResponse("getchampionranks", session, signature, timestamp, player)
return jsonify(response.json())
@app.route("/getstatus/<player>")
def getStatus(player):
session = getSession()
signature, timestamp = getSignature("getplayerstatus")
response = getResponse("getplayerstatus", session, signature, timestamp, player)
return jsonify(response.json())
# returns all occurrences of a nickname
@app.route("/searchplayers/<player>")
def searchPlayer(player):
session = getSession()
signature, timestamp = getSignature("searchplayers")
response = getResponse("searchplayers", session, signature, timestamp, player)
return jsonify(response.json())
@app.route("/getmatches/<player>")
def getMatches(player):
session = getSession()
signature, timestamp = getSignature("getmatchhistory")
response = getResponse("getmatchhistory", session, signature, timestamp, player)
return jsonify(response.json())
if __name__ == "__main__":
app.run()