Async Live API

Asked

Viewed 24 times

0

Can an API in Flask that fetches the live games from a website and returns them. However, this search takes about 40 seconds to be done (getDados() function), but I would like the user to receive the most recent data (it may be that during this request another is already being performed to update (asynchronous)). Could someone give me a light on how to accomplish this task? Below is how the API code is.

from flask import Flask
from flask import jsonify
from main2 import getDados

app = Flask(__name__)

@app.route("/")
def index():
    return "Hello World!"

@app.route("/jogos", methods=["GET"])
def jogos():
    dados = getDados()
    return jsonify(dados)
    

if __name__ == "__main__":
    app.run()
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.