I am trying to make a steam flask response in order to get a user`s friends and games
I keep getting the GET / HTTP/1.1
404 error.
Any advice on how to fix it? Also, how can I get a json response instead of flask?
from flask import Flask, jsonify
from steamapi import core, user
app = Flask("Steamer")
core.APIConnection(api_key="apikeygoeshere")
@app.route('/user/<name>')
def hello(name=None):
try:
try:
steam_user = user.SteamUser(userid=int(useridgoeshere))
except ValueError:
steam_user = user.SteamUser(userurl=usernamegoeshere)
name = steam_user.name
content = "Your real name is {0}. You have {1} friends and {2} games.".format(steam_user.real_name,
len(steam_user.friends),
len(steam_user.games))
img = steam_user.avatar
return jsonify('hello.html', name=name, content=content, img=img)
except Exception as ex:
return jsonify('hello.html', name=name)
if __name__ == '__main__':
app.run()
Not sure if this has any impact on the error, but the hello.html code is as follows:
<!doctype html>
<html>
<body>
<title>Hello there!</title>
{% if name %}
<h1>Hello {% if img %}<img src="{{ img }}" /> {% endif %}{{ name }}!</h1>
{% else %}
<h1>Hello Anonymous!</h1>
{% endif %}
{% if content %}
<p>{{ content }}</p>
{% endif %}
</body>
</html>
Response i get:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [01/Dec/2016 17:26:08] "GET / HTTP/1.1" 404 -