Apr 21, 2020 10:41
No problem. I hope you get it working.
Apr 21, 2020 10:38
Give it a go!
Apr 21, 2020 10:35
I'm just unsure on the implementation details regarding how you'd emit events to the client
Apr 21, 2020 10:35
Gevent works with flask, so you might just need that
Apr 21, 2020 10:34
You may not need FlaskSocketIO to be honest. Try googling for "long polling Flask"
Apr 21, 2020 10:32
Keep in mind that Bottle is a replacement for Flask here
Apr 21, 2020 10:26
It would definitely be worth the effort to look into what libraries they offer first, before moving to AWS
Apr 21, 2020 10:26
As I said, I have perosnally not used anything other that Flask-SocketIO for this kind of stuff so I won't be able to help
Apr 21, 2020 10:25
Well, sure, but you'd have to choose a library that works from what they currently have installed
Apr 21, 2020 10:24
Beanstalk doesn't support websockets, but I think in your case long-polling will do just fine.
Apr 21, 2020 10:23
It's definitely a bit more complicated because it involves more to setup, but there are lots of resources online on how to do it
Apr 21, 2020 10:22
I would suggest you look into Elastic Beanstalk, a service that Amazon Web Services (AWS) provide. It comes with a free tier.

They have a Flask tutorial.
Apr 21, 2020 10:20
It's a fair bit more complicated
Apr 21, 2020 10:20
Another options is AWS, have you used them before?
Apr 21, 2020 10:17
Yeah, you could try to use a different socket library but I have no idea if it will work well with flask.
Apr 21, 2020 10:17
Are you stuck with Pythonanywhere or are you able to host it somewhere else?
Apr 21, 2020 10:13
How did you install Flask on there to begin with?
Apr 21, 2020 10:13
I don't know how pythonanywhere works so I can't help you there unfortunately
Apr 21, 2020 10:09
Apr 21, 2020 10:09
yes you'd have to install it first
Apr 21, 2020 10:05
I have two concerns however:
1) It looks like you were using server-side rendering. Not sure how easy it will be to setup the frontend with socketio in this way.
2) It looks like you're using a pre-packaged solution to host your actual server. So I don't know what server tech they're using - they might not support websockets - in the worst case it won't matter much - it just means that you will be stuck with long-polling
Apr 21, 2020 10:03
You will need to add websocket support to your server. There is a great library called Flask-SocketIO for this.

On the client side you will need to use the socketIO library: https://socket.io/
Apr 21, 2020 10:01
Yes. I can point you the right direction
Apr 21, 2020 09:55
Or, just display a simple warning
Apr 21, 2020 09:55
All in all, I don't think it's worth the added complexity on the server for you to do all this. The cheaper way to do this would be to run a few simulations yourself, check the time it takes, and create a fake progress bar on the frontend
Apr 21, 2020 09:54
It's a small point, I was just talking in principle
Apr 21, 2020 09:53
Sure, but in the worst case they would see your progress bar say 100% and the image might take some time to arrive
Apr 21, 2020 09:52
In most cases, it won't matter
Apr 21, 2020 09:51
Yes, but downloading the image takes time
Apr 21, 2020 09:51
Technically speaking, I could be using this site on a crappy network and it might take me 2 mins just to download the image
Apr 21, 2020 09:51
The progress not only depends on the speed of the calculation, it also depends on the user's network speed
Apr 21, 2020 09:50
Here is another thing
Apr 21, 2020 09:50
You could even do it conditionally, based on the number they input
Apr 21, 2020 09:49
I really think that unless you opt to use websockets and learn a bit more about Javascript, that you just render a notice that warns the user that it might take a while
Apr 21, 2020 09:49
So here is what I would suggest
Apr 21, 2020 09:48
Yep, just testing it out now
Apr 21, 2020 09:48
Ok, looks good
Apr 21, 2020 09:46
That's fine, I was just trying to demonstrate the point that it adds additional problems
Apr 21, 2020 09:41
@Mick, it might be easier to chat here if you wish
Apr 21, 2020 09:41
I meant that it's not a good way to solve the problem. What if 1000s of users use your application? Your server will run out of memory pretty quickly - to tackle that you will need to write something that safely cleans up these leftovers. In fact you'd have to do it anyway, because overtime these files will pile up. Moreover, the client will only be checking the server every X seconds right? That means the rate of updates is limited by X. Unless you choose to do this properly, I would suggest that you simply render a message on the client that says this may take up to 2-3 minutes.
Apr 21, 2020 09:41
That is correct. You could do it, but it would not be great - for example, your my_job could also save in another file how much it has already processed. Then in the check_job endpoint you could read that file and return the percentage in the response. But, this would only be beneficial if the process you have is taking several minutes.At this stage you're adding so much complexity to your system for very little benefit.
Apr 21, 2020 09:41
Hi @Mick. The function (response) bit is a nameless function. The response is an arugment - in this case it represents the response from the server. Here, the then() function requires us to give it another function to execute when the request succeeds. So we define a nameless function right in there that will print a line to the console and will stop the while loop. What you mentioned about the percentage is not feasible, no; that's not how it works unfortunately.
 

React.js

this.setState({ status: 'open', description: 'React talk ...' });
Jul 11, 2019 14:01
I want to store the auth_status in my Redux store; this is easy but it gets obliterated on a full refresh.
Jul 11, 2019 14:00
Hi there. Can someone tell me the correct way to persist my user's logged in state with Redux?
 

Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Jun 25, 2019 09:55
I feel like I have done everything right in my setup, yet I am still unable to set cookies in my browser
Jun 25, 2019 09:54
Hey guys. I've been scratching my head over this issue with my Flask app for a while now. If anyone could take a look I would really appreciate it. stackoverflow.com/questions/56739519/…
Nov 17, 2017 12:51
@PM2Ring it's one of those binoculars you put money into, at tourist locations
Nov 17, 2017 12:49
anyone experienced with SQL Alchemy here? I need help modifying its behaviour which would most likely involve monkey patching
 

JavaScript

Topic: Anything JavaScript, ECMAScript including Node, React, ...
Jan 30, 2017 09:31
@OliverSalzburg if you graph hatred vs time, its probable more of an inverse parabola ;)
Jan 30, 2017 09:26
@OliverSalzburg yeah, I need to get used to some design patterns I guess... and overcome my hatred for functional programming