Flask

Flask send stream as response

ε祈祈猫儿з 提交于 2021-01-21 04:34:47
问题 I'm trying to "proxy" my Flask server (i will call it Server#01) with another server(Server#02). It's working well except for one thing : when the Server#01 use send_from_directory(), i don't know how to re-send this file. My classic "proxy" result = requests.get(my_path_to_server01) return Response(stream_with_context(result.iter_content()), content_type = result.headers['Content-Type']) With a file a response, it's taking hours... So i tried many things. The one who work is : result =

Flask send stream as response

爱⌒轻易说出口 提交于 2021-01-21 04:32:11
问题 I'm trying to "proxy" my Flask server (i will call it Server#01) with another server(Server#02). It's working well except for one thing : when the Server#01 use send_from_directory(), i don't know how to re-send this file. My classic "proxy" result = requests.get(my_path_to_server01) return Response(stream_with_context(result.iter_content()), content_type = result.headers['Content-Type']) With a file a response, it's taking hours... So i tried many things. The one who work is : result =

Flask – multiple session cookies with the same name

青春壹個敷衍的年華 提交于 2021-01-21 04:23:43
问题 I have found a very strange problem in my Flask application. I discovered that in some circumstances multiple session cookies could be created with the same name. I attached a picture about it. It is not browser specific. It is strange itself, but the real problem comes when I try to validate a form with CSRF token. Unfortunately, Flask picks a wrong session cookie and the validation of the CSRF token cannot be successful. And even more strangely the problem persists even after multiple form

Flask – multiple session cookies with the same name

故事扮演 提交于 2021-01-21 04:22:04
问题 I have found a very strange problem in my Flask application. I discovered that in some circumstances multiple session cookies could be created with the same name. I attached a picture about it. It is not browser specific. It is strange itself, but the real problem comes when I try to validate a form with CSRF token. Unfortunately, Flask picks a wrong session cookie and the validation of the CSRF token cannot be successful. And even more strangely the problem persists even after multiple form

Flask, processing requests 1 by 1

ぐ巨炮叔叔 提交于 2021-01-21 04:11:14
问题 I have a flask application which listens for some job to do. The process is quite long (let us say 1 minute) and I would like not allow to process two requests at the same time. I will be great if once I receive a request, I could close the port flask is listening to and open again when finish. Alternatively I could setup a semaphore but I am not sure about how flask is running concurrently. Any advice? from flask import Flask, request app = Flask(__name__) @app.route("/",methods=['GET']) def

Flask Dynamic dependent dropdown list

我们两清 提交于 2021-01-20 16:13:08
问题 I started reading into some flask application programming and I have been trying to get drop down menu to work, but so far I have had no luck. What I want to do is, when the user selects a Type of Food from the first dropdown list, it should get the corresponding list from the database and fill the second set of drop down list. I do not know how to make it send a quick request once a selection is made. I really don't understand what should be done here. <body> <div> <form action="{{ url_for(

Flask Dynamic dependent dropdown list

青春壹個敷衍的年華 提交于 2021-01-20 16:10:46
问题 I started reading into some flask application programming and I have been trying to get drop down menu to work, but so far I have had no luck. What I want to do is, when the user selects a Type of Food from the first dropdown list, it should get the corresponding list from the database and fill the second set of drop down list. I do not know how to make it send a quick request once a selection is made. I really don't understand what should be done here. <body> <div> <form action="{{ url_for(

Flask Admin - how to set form_edit_rules or form_create_rules based on role of user?

这一生的挚爱 提交于 2021-01-20 12:10:27
问题 I am making simple ticketing system for medium-sized organization using Flask and sqlite together with SQLAlchemy. For backend managing of data I use Flask-Admin. The User and Ticket table looks like this: class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) role = db.Column(db.Integer, default=0) vmc_kom = db.Column(db.String(20)) name = db.Column(db.String(30), nullable=False) phone = db.Column(db.String, default="not") email = db.Column(db.String(40), nullable

Flask Admin - how to set form_edit_rules or form_create_rules based on role of user?

自古美人都是妖i 提交于 2021-01-20 12:09:42
问题 I am making simple ticketing system for medium-sized organization using Flask and sqlite together with SQLAlchemy. For backend managing of data I use Flask-Admin. The User and Ticket table looks like this: class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) role = db.Column(db.Integer, default=0) vmc_kom = db.Column(db.String(20)) name = db.Column(db.String(30), nullable=False) phone = db.Column(db.String, default="not") email = db.Column(db.String(40), nullable

Flask Admin - how to set form_edit_rules or form_create_rules based on role of user?

久未见 提交于 2021-01-20 12:07:30
问题 I am making simple ticketing system for medium-sized organization using Flask and sqlite together with SQLAlchemy. For backend managing of data I use Flask-Admin. The User and Ticket table looks like this: class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) role = db.Column(db.Integer, default=0) vmc_kom = db.Column(db.String(20)) name = db.Column(db.String(30), nullable=False) phone = db.Column(db.String, default="not") email = db.Column(db.String(40), nullable