-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (37 loc) · 1.73 KB
/
Copy pathmain.py
File metadata and controls
48 lines (37 loc) · 1.73 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
from flask import Flask, render_template, url_for, redirect, request
from steamapi import core, user, store
app = Flask("Steamer")
core.APIConnection(api_key="97EBFD00E4237E4C049D0EAE5A80ADCC")
@app.route('/post/profile/', methods=['POST'])
def set_profile():
if request.method == 'POST':
name = request.form['profile_name']
else:
name = ''
return redirect(url_for('view_profile', name=name))
@app.route('/user/view/')
def view_redirect():
return redirect(url_for('view_profile', name='unknown'))
@app.route('/user/view/<name>/')
def view_profile(name=None):
try:
try:
steam_user = user.SteamUser(userid=int(name))
except ValueError: # Not an ID, but a vanity URL.
steam_user = user.SteamUser(userurl=name)
name = steam_user.real_name
profile_url = steam_user.profile_url
level = steam_user.level
xp = steam_user.xp
content = "Your username is {0}. You have {1} friends and {2} games.".format(steam_user.name,
len(
steam_user.friends),
len(steam_user.games))
img = steam_user.avatar_full
return render_template('index.html', name=name, content=content, img=img, profile_url=profile_url, level =level,xp=xp)
except Exception as ex:
# We might not have permission to the user's friends list or games, so
# just carry on with a blank message.
return render_template('index.html', name=name)
if __name__ == '__main__':
app.run(debug=True)