Flask

How to set FLASK_APP with custom project structure

强颜欢笑 提交于 2020-07-09 12:39:05
问题 Despite trial and error I cannot get the command 'flask shell' to run. This is what happens when i run flask shell from the project dir: $ set FLASK_APP= Error: While importing "project_dir.wsgi", an ImportError was raised: [...] from flask_app.app import construct_app ModuleNotFoundError: No module named 'flask_app' $ set FLASK_APP=wsgi ModuleNotFoundError: No module named 'flask_app' $ set FLASK_APP=flask_app\__init__.py:construct_app Error: module 'backoffice_nova.flask_app' has no

How to send image in C# to a Flask Server that is decoded by OpenCV?

我的梦境 提交于 2020-07-09 11:50:21
问题 Here is part of my Flask API in Python: image_data = flask.request.get_data() # image_data's data type string image_vector = numpy.frombuffer(image_data, dtype=numpy.uint8) image = cv2.imdecode(image_vector, cv2.IMREAD_COLOR) How would I send a image that I encoded like below, in C#: ResultString = "Loading..."; var surface = SKSurface.Create(new SKImageInfo((int)canvasView.CanvasSize.Width, (int)canvasView.CanvasSize.Height)); var canvas = surface.Canvas; canvas.Clear(); foreach (SKPath path

How to send image in C# to a Flask Server that is decoded by OpenCV?

社会主义新天地 提交于 2020-07-09 11:46:46
问题 Here is part of my Flask API in Python: image_data = flask.request.get_data() # image_data's data type string image_vector = numpy.frombuffer(image_data, dtype=numpy.uint8) image = cv2.imdecode(image_vector, cv2.IMREAD_COLOR) How would I send a image that I encoded like below, in C#: ResultString = "Loading..."; var surface = SKSurface.Create(new SKImageInfo((int)canvasView.CanvasSize.Width, (int)canvasView.CanvasSize.Height)); var canvas = surface.Canvas; canvas.Clear(); foreach (SKPath path

Flash messaging not working in Flask

我怕爱的太早我们不能终老 提交于 2020-07-09 10:14:35
问题 I have been unable to get the flash function to work in flask. Heres my code. #!venv/bin/python3 from flask import Flask, flash app = Flask(__name__) app.config['SECRET_KEY'] = '12345' @app.route('/') def index(): flash('Hi') return 'Hello' if __name__ == '__main__': app.run() I expected this to flash a message saying hi but when I load the page no flash box appears. What am I not understanding here? 回答1: I think the main problem is that you're returning a string and not a render_template

Flash messaging not working in Flask

时光毁灭记忆、已成空白 提交于 2020-07-09 10:11:55
问题 I have been unable to get the flash function to work in flask. Heres my code. #!venv/bin/python3 from flask import Flask, flash app = Flask(__name__) app.config['SECRET_KEY'] = '12345' @app.route('/') def index(): flash('Hi') return 'Hello' if __name__ == '__main__': app.run() I expected this to flash a message saying hi but when I load the page no flash box appears. What am I not understanding here? 回答1: I think the main problem is that you're returning a string and not a render_template

Docker: Running a Flask app via Gunicorn - Worker timeouts? Poor performance?

一个人想着一个人 提交于 2020-07-09 06:52:47
问题 I am trying to create a new app that is written in Python Flask, run by gunicorn and then dockerised. The problem I have is the performance inside the docker container is very poor, inconsistent and I do eventually get a response but I can't understand why the performance is decreasing. Sometimes I see in the logs [CRITICAL] WORKER TIMEOUT (pid:9) . Here is my app: server.py from flask import Flask app = Flask(__name__) @app.route('/') def index(): return "The server is running!" if __name__

Docker: Running a Flask app via Gunicorn - Worker timeouts? Poor performance?

不羁岁月 提交于 2020-07-09 06:52:27
问题 I am trying to create a new app that is written in Python Flask, run by gunicorn and then dockerised. The problem I have is the performance inside the docker container is very poor, inconsistent and I do eventually get a response but I can't understand why the performance is decreasing. Sometimes I see in the logs [CRITICAL] WORKER TIMEOUT (pid:9) . Here is my app: server.py from flask import Flask app = Flask(__name__) @app.route('/') def index(): return "The server is running!" if __name__

Docker: Running a Flask app via Gunicorn - Worker timeouts? Poor performance?

送分小仙女□ 提交于 2020-07-09 06:52:05
问题 I am trying to create a new app that is written in Python Flask, run by gunicorn and then dockerised. The problem I have is the performance inside the docker container is very poor, inconsistent and I do eventually get a response but I can't understand why the performance is decreasing. Sometimes I see in the logs [CRITICAL] WORKER TIMEOUT (pid:9) . Here is my app: server.py from flask import Flask app = Flask(__name__) @app.route('/') def index(): return "The server is running!" if __name__

WTF form.validate_on_submit() not working

匆匆过客 提交于 2020-07-09 06:13:13
问题 I have the following code and I'm submitting a form. When I hit the submit button, my form validation prints out False . I've checked and made sure I'm including everything from different posts, but I can't get it to validate. Is there anything I'm doing wrong? @app.route('/index.html', methods=['GET', 'POST']) def index(): user = {'nickname': 'Rafa'} form = FilterForm() print("about to validate", file=sys.stderr) if form.validate_on_submit(): print("validated", file=sys.stderr) filters_array

Flask bcrypt.check_password_hash() always returns False, can't narrow in on my mistake

大憨熊 提交于 2020-07-09 05:35:11
问题 While trying to write a login functionality in flask, I wanted to try 'bcrypt' flask extensio. When I use_bcrypt.check_password_hash()_ method to compare user form input password against that users saved password in the db, it always returns false. Here is the code I use to generate passwords: hashPwd = bcrypt.generate_password_hash('form.password.data') Here is the code I use to check the candidate password against the saved one: if form.validate_on_submit(): user = User.query.filter_by