-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.py
More file actions
86 lines (67 loc) · 3.21 KB
/
app.py
File metadata and controls
86 lines (67 loc) · 3.21 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from flask import Flask, render_template, url_for, redirect, request
import os
from dotenv import load_dotenv
from api import MatchHistory as MH
from api import LiveGame as LG
from helpers import GenericImages as GI
from helpers import RegionDetails as RD
from helpers import UserID as UID
from helpers import cache
#------------------------------------------------------------------------------------------------------
load_dotenv()
api = os.getenv('RIOT_API_KEY')
#------------------------------------------------------------------------------------------------------
app = Flask(__name__)
@app.route('/', methods=['POST','GET'])
def Home():
Page_Info = {'Title': 'LolStat - Home'}
return render_template('home.html', PAGE_INFO=Page_Info)
#------------------------------------------------------------------------------------------------------
@app.route('/lol', methods=['POST'])
def Lol():
username = str(request.form['username'])
region = str(request.form['region'])
if username and region:
return redirect(f"/lol/{region}/{username}")
return "Please enter both username & password"
@app.route('/lol/<region>/<username>', methods=['GET'])
def MatchHistory(region, username):
shard = RD.getShard(region)
version = RD.getVersion(api, region)
user_info = UID.getUser(api, region, username)
profile = UID.getRankInfo(api, region, user_info['summonerID'])
match_ids = MH.getMatchIDs(api, shard, user_info['puuID'],)
match_details = MH.getAllMatchDetails(api, shard, match_ids)
match_info = MH.getMatchInfo(match_details)
match_player_info = MH.getMatchPlayersDetails(version, match_details)
# live_player_info = LG.getLiveGameInfo(api, region, version, user_info['summonerID'])
PageInfo = {
'Title': f"{user_info['name']} - Match History",
'Username': user_info['name'],
'len': len(match_player_info),
'region': region
}
return render_template('MatchHistory.html', PAGE_INFO=PageInfo, Player_Details=match_player_info, Match_Details=match_info, Profile=profile )
# TEST ------------------------------------------------------------------------------------------------
@app.route('/test', methods=['POST'])
def Test():
username = str(request.form['username'])
region = str(request.form['region'])
if username and region:
return redirect(f"/test/{region}/{username}")
return "Please enter both username & password"
@app.route('/test/<region>/<username>', methods=['GET'])
def TestJSON(region, username):
shard = RD.getShard(region)
version = RD.getVersion(api, region)
user_info = UID.getUser(api, region, username)
profile = UID.getRankInfo(api, region, user_info['summonerID'])
match_ids = MH.getMatchIDs(api, shard, user_info['puuID'],)
match_details = MH.getAllMatchDetails(api, shard, match_ids)
match_info = MH.getMatchInfo(match_details)
match_player_info = MH.getMatchPlayersDetails(version, match_details)
live_player_info = LG.getLiveGameInfo(api, region, version, user_info['summonerID'])
return profile
#------------------------------------------------------------------------------------------------------
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')