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
12
votes
2 answers

How to display a pandas dataframe as datatable?

I want to display a table - which is a pandas dataframe - as a DataTable. In the simplified example below, I read two numbers provided by a user, that determine the row and column number of the table. The number of elements of this table is then…
Cleb
  • 25,102
  • 20
  • 116
  • 151
12
votes
2 answers

How do I embed a Flask-Security login form on my page?

Using the example code provided by Flask-Security, I can access the login_user.html form from the /login route normally and that works just fine. However, I would like to embed the login form on all my site's pages in the upper left. I thought I…
Nicholas Tulach
  • 1,023
  • 3
  • 12
  • 35
12
votes
5 answers

Flask's built-in server always 404 with SERVER_NAME set

Here is a minimal example: from flask import Flask app = Flask(__name__) app.config['DEBUG'] = True app.config['SERVER_NAME'] = 'myapp.dev:5000' @app.route('/') def hello_world(): return 'Hello World!' @app.errorhandler(404) def…
nalzok
  • 14,965
  • 21
  • 72
  • 139
12
votes
5 answers

How to get current user when implementing Python Flask-Security?

I am using Flask-Security to set up user authentication for my app but I am struggling with getting the email address or ID of the currently logged in user so I can query a table with that particular users details. I've just using the standard…
Johnny John Boy
  • 3,009
  • 5
  • 26
  • 50
12
votes
1 answer

How to run Flask app as a package in PyCharm

I was following this documentation on directory management for Flask projects. Now, I'm trying to run my flask application from PyCharm. I have added the below mentioned Environment Variables in Edit…
shubhamsingh
  • 402
  • 3
  • 8
  • 21
12
votes
2 answers

Converting Flask form data to JSON only gets first value

I want to take input from an HTML form and give the output in JSON format. When multiple values are selected they are not converted into JSON arrays, only the first value is used. @app.route('/form') def show_form(): return…
Aditya Pednekar
  • 442
  • 2
  • 6
  • 19
12
votes
1 answer

Flask - store object directly in a session

I was wondering if it is possible to store an object directly in a Flask session, without the need to rewrite the serializer. Are there any functions I need to implement in my class in order to get this working? Sample code that is below. This is…
fweidemann14
  • 1,714
  • 3
  • 13
  • 20
12
votes
2 answers

docker-compose volume not mounting correctly

I am following the flask/docker tutorial on testdriven.io. Within Part One on the third section Docker Config I am following the instructions in order to mount the project directory as a volume within the docker container for development.…
Jonnyishman
  • 365
  • 3
  • 4
  • 12
12
votes
1 answer

Flask - how to read request.files['image'] as base64?

I'm using Python Flask as my backend and faced a little problem. In the frontend application I have a form that contains an image upload feature. In the backend I refer a variable to the image with image = request.files['image'] That exports a…
GMe
  • 1,091
  • 3
  • 13
  • 24
12
votes
2 answers

What is the best way to sanitize inputs with Flask and when using MongoDB?

I'm writing my application backend with Python Flask. As part of the registration process, I have a form that sends the new user's information to my backend and then adds it to my MongoDB database. I'm pretty new in this world and never wrote…
GMe
  • 1,091
  • 3
  • 13
  • 24
12
votes
4 answers

Is it safe to store my 'next' url in a signed cookie and redirect to it carefree?

I'm using Flask and it's occurred to me it could be a rather elegant solution to redirect back to the user's last page after login/logout by simply placing a session['next'] = request.url at each endpoint of my application and to just have my…
chrickso
  • 2,994
  • 5
  • 30
  • 53
12
votes
5 answers

Change static folder from config in Flask

Has anyone tried this snippet flask config based static folder code cnippet? The code: import flask class MyFlask(flask.Flask): @property def static_folder(self): if self.config.get('STATIC_FOLDER') is not None: return…
Nurjan
  • 5,889
  • 5
  • 34
  • 54
12
votes
1 answer

How can I share a cache between Gunicorn workers?

I am working on a small service using Gunicorn and Flask (Python 3.6).The pseudocode below shows roughly the behavior I want. There are a lot of serialized foo objects, and I want to hold as many of these in memory as possible and delete them on a…
user910210
  • 193
  • 4
  • 10
12
votes
1 answer

Why must a Flask session's value be JSON serializable?

I'm trying to instantiate a basic Model instance for the user session in my Flask application. I'm caught off guard by the requirement that my class be JSON serializable. I thought the session dictionary was just an arbitrary construct to store…
jxramos
  • 7,356
  • 6
  • 57
  • 105
12
votes
5 answers

Running Flask app in a Docker container

I've built a Docker image containing a simple Flask test app: from flask import Flask app = Flask(__name__) @app.route("/") def hello_world(): return "Hello World!" if __name__ == "__main__": app.run(debug=True,host='0.0.0.0') using the…
srm
  • 548
  • 1
  • 4
  • 19
1 2 3
99
100