0

so i want to make something like a progress bar in js(react) and in python(flask)

and I want to return to the react that he needs to change the progress bar.

React:

    fetch(pythonUrl+"/NormalMyProgress",
    {
        method: 'POST',
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        
        body: new URLSearchParams( 
        {
           
            "text" : "hello"
        })
    })
    .then(resp => resp.json())
    .then(data => 
    {
        setProgressBarValue(data.data)

    })  

python:

@app.route('/NormalMyProgress',methods=["POST"])
def home_normal():
    txt = request.form.get('text')
    print(txt)
    for i in [0,25,50,100]
       return jsonify({"data":i})
Gad
  • 154
  • 8
  • Do you consider using WebSocket so that you don't need to keep posting Data from client. – EnergyBoy Aug 31 '22 at 15:59
  • How can I use it? – Gad Aug 31 '22 at 16:07
  • [Server-sent events](https://stackoverflow.com/questions/12232304/how-to-implement-server-push-in-flask-framework) are also possible. – ggorlen Aug 31 '22 at 16:08
  • Does this answer your question? [How to implement server push in Flask framework?](https://stackoverflow.com/questions/12232304/how-to-implement-server-push-in-flask-framework) – ggorlen Aug 31 '22 at 16:09
  • I hope this gives you some idea https://blog.miguelgrinberg.com/post/add-a-websocket-route-to-your-flask-2-x-application – EnergyBoy Aug 31 '22 at 16:10
  • @ggorlen That is also awesome solution I haven't done that before. Thanks for sharing – EnergyBoy Aug 31 '22 at 16:11

0 Answers0