Fixed Serving
This commit is contained in:
parent
3f1dfd6f94
commit
643fab371a
|
|
@ -10,13 +10,13 @@ import asyncio
|
|||
|
||||
app = Flask(__name__)
|
||||
|
||||
data_dict = {}
|
||||
|
||||
|
||||
|
||||
@app.route("/", methods=["POST", "GET"])
|
||||
async def index():
|
||||
global data_dict
|
||||
|
||||
data_dict = {}
|
||||
|
||||
if request.method == "POST":
|
||||
status_screen = request.form["status_screen_input"]
|
||||
steamids = regex_for_steamids(status_screen)
|
||||
|
|
@ -27,12 +27,26 @@ async def index():
|
|||
data_dict[steamid] = {}
|
||||
data_dict[steamid]['steamid64'] = steamid_to_64bit(steamid)
|
||||
|
||||
task_get_faceit_data = asyncio.create_task(loop_faceit_data())
|
||||
task_get_steam_data = asyncio.create_task(loop_steam_data())
|
||||
task_get_faceit_data = asyncio.create_task(loop_faceit_data(data_dict))
|
||||
task_get_steam_data = asyncio.create_task(loop_steam_data(data_dict))
|
||||
|
||||
|
||||
await task_get_faceit_data
|
||||
await task_get_steam_data
|
||||
faceit_dict = await task_get_faceit_data
|
||||
steam_dict = await task_get_steam_data
|
||||
|
||||
for steamid in faceit_dict:
|
||||
if faceit_dict[steamid]['faceit_acc'] == 'true' :
|
||||
data_dict[steamid]['faceit_elo'] = faceit_dict[steamid]['faceit_elo']
|
||||
data_dict[steamid]['faceit_level'] = faceit_dict[steamid]['faceit_level']
|
||||
data_dict[steamid]['faceit_name'] = faceit_dict[steamid]['faceit_name']
|
||||
data_dict[steamid]['faceit_acc'] = faceit_dict[steamid]['faceit_acc']
|
||||
else:
|
||||
data_dict[steamid]['faceit_acc'] = faceit_dict[steamid]['faceit_acc']
|
||||
|
||||
for steamid in steam_dict:
|
||||
data_dict[steamid]['steam_name'] = steam_dict[steamid]['steam_name']
|
||||
data_dict[steamid]['steam_pic'] = steam_dict[steamid]['steam_pic']
|
||||
|
||||
|
||||
return render_template('steamids.html', data_dict = data_dict)
|
||||
else:
|
||||
|
|
@ -59,10 +73,10 @@ def steamid_to_64bit(steamid):
|
|||
return steam64id
|
||||
|
||||
|
||||
async def loop_faceit_data():
|
||||
global data_dict
|
||||
|
||||
async def loop_faceit_data(data_dict):
|
||||
faceit_dict = {}
|
||||
for steamid in data_dict:
|
||||
faceit_dict[steamid] = {}
|
||||
url = "https://open.faceit.com/data/v4/players?game=csgo&game_player_id=" + str(data_dict[steamid]['steamid64'])
|
||||
headers = { 'accept': 'application/json', 'Authorization' : 'Bearer ab46a7ab-6ab8-4c00-a8ff-41c0ff71d562' }
|
||||
faceit_response = requests.get(url, headers=headers)
|
||||
|
|
@ -70,22 +84,28 @@ async def loop_faceit_data():
|
|||
|
||||
|
||||
try:
|
||||
data_dict[steamid]['faceit_elo'] = faceit_response_json['games']['csgo']['faceit_elo']
|
||||
data_dict[steamid]['faceit_level'] = faceit_response_json['games']['csgo']['skill_level']
|
||||
data_dict[steamid]['faceit_name'] = faceit_response_json['nickname']
|
||||
data_dict[steamid]['faceit_acc'] = 'true'
|
||||
faceit_dict[steamid]['faceit_elo'] = faceit_response_json['games']['csgo']['faceit_elo']
|
||||
faceit_dict[steamid]['faceit_level'] = faceit_response_json['games']['csgo']['skill_level']
|
||||
faceit_dict[steamid]['faceit_name'] = faceit_response_json['nickname']
|
||||
faceit_dict[steamid]['faceit_acc'] = 'true'
|
||||
except:
|
||||
data_dict[steamid]['faceit_acc'] = 'false'
|
||||
faceit_dict[steamid]['faceit_acc'] = 'false'
|
||||
|
||||
return faceit_dict
|
||||
|
||||
async def loop_steam_data():
|
||||
global data_dict
|
||||
async def loop_steam_data(data_dict):
|
||||
steam_dict = {}
|
||||
for steamid in data_dict:
|
||||
steam_dict[steamid] = {}
|
||||
steamurl ="https://steamcommunity.com/profiles/" + str(data_dict[steamid]['steamid64']) +"/?xml=1"
|
||||
steam_req = requests.get(steamurl)
|
||||
steamdict_funct = xmltodict.parse(steam_req.content)
|
||||
|
||||
data_dict[steamid]['steam_name'] = steamdict_funct['profile']['steamID']
|
||||
data_dict[steamid]['steam_pic'] = steamdict_funct['profile']['avatarFull']
|
||||
steam_dict[steamid]['steam_name'] = steamdict_funct['profile']['steamID']
|
||||
steam_dict[steamid]['steam_pic'] = steamdict_funct['profile']['avatarFull']
|
||||
|
||||
return steam_dict
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue