-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
Description
I have an issue with creating a small web application whuch will wait for request with profile id and return it's profile card, but it seems like jobs and events are not working when hosting it as Flask or FastAPI apps. For me it seems like a bug but I'm not sure.
Do you have ideas?
from steam.client import SteamClient
from dota2.client import Dota2Client
from flask import Flask, Response
logging.basicConfig(
format='[%(asctime)s] %(levelname)s %(name)s: %(message)s', level=logging.DEBUG)
username = "login"
password = "password"
app = Flask(__name__)
steamClient = SteamClient()
dota = Dota2Client(steamClient)
@dota.on('ready')
def fetch_profile_card():
logging.info('Logged in to Dota 2')
pass
@dota.on('profile_card')
def print_profile_card(account_id, profile_card):
if profile_card:
logging.log("Got the profile card")
# @app.get("/getPlayerProfile/{playerId}") # use this for FaskAPI
@app.route('/getPlayerProfile/<int:playerId>', methods=['GET'])
def getUserProfile(playerId):
logging.log(logging.INFO, 'Got GETUSERPROFILE event with %d player ID' % int(playerId))
# we hardcode here so you can send everything you want it will try to obtain profile card from tutorial
jobid = dota.request_profile_card(70388657)
profile_card = dota.wait_msg(jobid, timeout=10)
if profile_card:
return Response(status=200, response='event emited and got profile card')
else:
return Response(status=404, response='event emited and got no profile card')
try:
if dota.ready is not True:
steamClient.login(username, password, login_id=774)
dota.launch()
dota.wait_event('ready')
app.run()
except KeyboardInterrupt:
steamClient.logout()
Venahprog