Questions tagged [flask]

Flask is a lightweight framework for developing web applications using Python.

Flask is a web application framework for . It has exceptional documentation, a large number of extensions and a friendly community on Discord. It is open source and BSD-3-Clause licensed.

Resources

Related Tags

54068 questions
13
votes
1 answer

How to I delete all Flask sessions?

How do I delete all sessions and cookies set by my Flask/python app. So that when users return they have to re-login. I want to do this each time I push a new version of the code to production otherwise.
nickponline
  • 25,354
  • 32
  • 99
  • 167
13
votes
3 answers

How to actually upload a file using Flask WTF FileField

In my forms.py file I have I have class myForm(Form): fileName = FileField() In my views.py file I have form = myForm() if form.validate_on_submit(): fileName = secure_filename(form.fileName.file.filename) In my .html…
Siecje
  • 3,594
  • 10
  • 32
  • 50
13
votes
1 answer

Running flask + gevent + requests not serving 'concurrently'

I kick off my flask app like this: #!flask/bin/python from app import app_instance from gevent.pywsgi import WSGIServer #returns and instance of the application - using function to wrap configuration app = app_instance() http_server =…
fansonly
  • 1,150
  • 4
  • 14
  • 29
13
votes
2 answers

WTForms creating a custom widget

The WTForms documentation is woefully inadequate, they don't even show you one single example of a custom widget that isn't derived from another widget already. I am trying to make a button type, that isn't an in html: submit =…
Dexter
  • 6,170
  • 18
  • 74
  • 101
13
votes
2 answers

Flask and Transfer-Encoding: chunked

We're trying get a Flask web service working, and we're having some issues with streaming posts - i.e. when the header includes Transfer-Encoding: chunked. It seems like the default flask does not support HTTP 1.1. Is there a work around for…
James Percent
  • 131
  • 1
  • 1
  • 5
13
votes
1 answer

flask-login: Chrome ignoring cookie expiration?

I've got the authentication working with flask-login, but it seems like no matter what I use for the cookie duration in flask, the session is still authenticated. Am I setting the config variables properly for flask-login? I've…
reptilicus
  • 10,290
  • 6
  • 55
  • 79
13
votes
1 answer

Flask-WTFform: Flash does not display errors

I'm trying to flash WTForm validation errors. I found this snippet and slightly modified it: def flash_errors(form): """Flashes form errors""" for field, errors in form.errors.items(): for error in errors: flash(u"Error…
Sean W.
  • 4,944
  • 8
  • 40
  • 66
13
votes
2 answers

Flask App Using WTForms with SelectMultipleField

I have a Flask application that uses WTForms for user input. It uses a SelectMultipleField in a form. I can't seem to get the app to POST all items in the field when selected; it only sends the first item selected regardless of how many the user…
Raj
  • 3,791
  • 5
  • 43
  • 56
13
votes
6 answers

Flask + mod_wsgi automatic reload on source code change

Does anyone know how to make a mod_wsgi automatically reload a Flask app when any of the modules changes? I've tried WSGIScriptReloading On, but no luck. The official documentation is kind of a bear ... I guess I'll give it a stab if no one knows.…
gatoatigrado
  • 16,580
  • 18
  • 81
  • 143
13
votes
1 answer

Flask app occasionally hanging

I've been working on a Flask app which handles SMS messages using Twilio, stores them in a database, and provides access to a frontend via JSONP GET requests. I've daemonized it using supervisord, which seems to be working pretty well, but every few…
flatpickles
  • 2,198
  • 2
  • 15
  • 21
13
votes
2 answers

Flask Babel - 'translations/de/LC_MESSAGES/messages.po' is marked as fuzzy, skipping

I cant get a basic translationto work in Flask Babel. Here are my steps. I have this in a page {{_("Hello")}} I run this command. pybabel extract -F babel.cfg -o messages.pot . I then run this command for German. pybabel init -i messages.pot -d…
Tampa
  • 75,446
  • 119
  • 278
  • 425
13
votes
3 answers

jinja2 first x items in for ... if loop

I have the following loop in my jinja2 template {% for item in list if item.author == 'bob' %} I am trying to get the first 5 items who have bob as an author. I tried doing {% for item in list if item.author == 'bob' and loop.index <= 5 %} but it…
applechief
  • 6,615
  • 12
  • 50
  • 70
13
votes
0 answers

Place to initialize DB in Flask

I'm developing app in Flask and it requires DB, so what I have is I do: app = Flask(__name__) @app.before_request def init_db_connection: # here I connect to my DB @app.teardown_request def destroy_db(exception): # here I destroy database…
Ignas Butėnas
  • 6,061
  • 5
  • 32
  • 47
13
votes
4 answers

Flask not getting any data from jQuery request data

I've a handler for a URL, @app.route("/", methods=['POST']) @crossdomain(origin='*') def hello(): ss=str(request.data) print ss return ss The handler cannot retrive the data part of the request. When using jQuery: jQuery.ajax( { …
Noor
  • 19,638
  • 38
  • 136
  • 254
13
votes
3 answers

How do I close a Server-Send Events connection in Flask?

The below has given an answer using node.js. How to close a "Server-Sent Events"-connection on the server? However, how to do the same thing in python Flask?
hllau
  • 9,879
  • 7
  • 30
  • 35