Posts

Showing posts with the label flask

Flask stuck loading after opening a certain route with a function

Flask stuck loading after opening a certain route with a function I'm relatively new to Python and Flask. I've been trying to create a web application that reads data readings from a .txt file and plots them onto a matplotlib plot. In this web-app, I have a front page with 3 buttons. These buttons redirect to different routes with functions that read data and plot them onto a matplotlib plot. The web-app works perfectly only for the first time I go to either of these routes. After that nothing loads anymore. I guess I have an infinite loop of some sort but I can't figure it out. Also, after the website gets stuck the Python process starts consuming more resources. The problem persists only when I open this route on the web-app: @app.route("/temperature/") This loads without problems on the web-page, but only for one time and the whole web-app gets stuck and I cannot access any of the other routes either. Thanks in advance! EDIT 1 - Whole code below cloudapp.py (P...

psycopg2 close connection pool

psycopg2 close connection pool I'm developing a Flask API, and I have the following code to have a connection pool using Psycopg2. I wonder should I consider to close the connection pool when the program terminates and how should I do this? @contextmanager def get_cursor(: global connection_pool if not cls.connection_pool: cls.connection_pool = ThreadedConnectionPool(5, 25, dsn=PoolingWrap.generate_conn_string()) con = cls.connection_pool.getconn() try: yield con.cursor(cursor_factory=RealDictCursor) finally: cls.connection_pool.putconn(con) Before going for an answer, I'd like to know if there's a reason you aren't using sqlalchemy, which has ways that help you handle this. – Luis Orduz Jun 26 at 13:59 what server are you using? – Ma...

How to check for the Local file deletion in flask before upload

How to check for the Local file deletion in flask before upload I am writing a web application where the user can upload the file. Now the question is how to check whether the file exists or not before file upload. In my case, I press the browse button in html page, select the file for upload now I delete the local file and press the upload button. There is no response from the website it keeps on running how to solve this. P.S Give reason before downvoting By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Sending live video frame over network to a remote server in python opencv [closed]

Sending live video frame over network to a remote server in python opencv [closed] I am trying to send frames that I am catching with my camera using opencv to a remote server, I tried to build a Rest Service using Flask, also I tried to use the socket, but the problem with this two solution is that both are too slow, and I'am looking for a real time solution. Can someone help? Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. probably not the sockets are too slow but your bandwidth isn't big enough. Calculate your bandwidth needs by image width times image height times bits per pixel times frames per second. Typically you'll need some good image encoding, if you don't use a gigabi...