🌐
Hackers and Slackers
hackersandslackers.com › configure-flask-applications
Configuring Your Flask App
September 30, 2018 - Best practices on configuring Flask. Use different configs for different environments and keep sensitive values out of your source code.
🌐
Flask
flask.palletsprojects.com › en › stable › config
Configuration Handling — Flask Documentation (3.1.x)
Applications need some kind of configuration. There are different settings you might want to change depending on the application environment like toggling the debug mode, setting the secret key, and other such environment-specific things. The way Flask is designed usually requires the configuration ...
Discussions

Flask Configuration for multiple instances. Best practices? - Stack Overflow
In flask the configuration module is pretty-straight forward and there are ample best practices on the same topic from internet. If I had to develop an Application which supports multiple instance... More on stackoverflow.com
🌐 stackoverflow.com
March 25, 2018
Python app configuration best practices - Stack Overflow
I know this issue has been discussed before, but I am struggling to find a starightforward explanation of how to approach configuration between local development and production server. What I hav... More on stackoverflow.com
🌐 stackoverflow.com
What are the best practices and standard conventions for routes?
In previous versions of flask, you had to do @app.route(methods=...). Nowadays you can do @app.post etc. They are functionally equivalent. But I recommend you go change all the @app.route to @app.post etc. if you can. The only time you cannot is if it is handling more than one method at once. In that case I would recommend breaking it out into two functions. More on reddit.com
🌐 r/flask
2
5
March 5, 2024
How do I write a Flask config file?
This doesn’t answer your question directly, but when I was learning flask I used this tutorial https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world and I can’t recommend it enough. The guy explains what he is doing and why it is needed. There is a part on Section 3 where he creates the config.py file which might be of some use? More on reddit.com
🌐 r/flask
7
9
February 14, 2019
🌐
DEV Community
dev.to › hackersandslackers › configuring-your-flask-app-2246
Configuring Your Flask App - DEV Community
May 15, 2022 - Encrypting data in Flask depends on the randomness of this string, which means decrypting the same data is as simple as getting a hold of this string's value. Guard your secret key with your life; ideally, even you shouldn't know the value of this variable. SERVER_NAME: If you intend your app to be reachable on a custom domain, we specify the app's domain name here. Configuration for serving static assets via the Flask-Assets library:
🌐
Readthedocs
explore-flask.readthedocs.io › en › latest › configuration.html
Configuration — Explore Flask 1.0 documentation
Sometimes you’ll need to define configuration variables that contain sensitive information. We’ll want to separate these variables from those in config.py and keep them out of the repository. You may be hiding secrets like database passwords and API keys, or defining variables specific to a given machine. To make this easy, Flask gives us a feature called instance folders.
🌐
Beautiful Soup
tedboy.github.io › flask › flask_doc.config.html
1 Configuration Handling — Flask API
Applications need some kind of configuration. There are different settings you might want to change depending on the application environment like toggling the debug mode, setting the secret key, and other such environment-specific things. The way Flask is designed usually requires the configuration ...
🌐
Pythonise
pythonise.com › series › learning-flask › flask-configuration-files
Flask configuration files | Learning Flask Ep. 12 | pythonise.com
February 14, 2019 - Loading a config file is a simple one liner and should be placed as close to wherever you've created your app object. It's best practice to load the config as soon as possible, just after your app object is created so any other extension has access to your configuration variables.
🌐
Medium
sairamkrish.medium.com › python-configuration-management-for-flask-based-application-741cdcad96c
Python configuration management for flask based application | by Sairam Krish | Medium
March 9, 2021 - As a best practice, keeping it as a python file, avoids giving wrong idea to end users. Dynaconf — Very promising. full docs on https://dynaconf.com · Python-dotenv — Get and set values in your .env file in local and production servers ...
🌐
Stack Overflow
stackoverflow.com › questions › 49476894 › flask-configuration-for-multiple-instances-best-practices
Flask Configuration for multiple instances. Best practices? - Stack Overflow
March 25, 2018 - class project_config: def __init__(self): with open(config_full_path, 'r') as myfile: configuration_raw = json.load(myfile) In Flask, the config module best practices was suggested as below
🌐
FedMSG
fedmsg.com › home › introduction to flask configuration
Flask App Configuration: Best Practices and Techniques
January 26, 2024 - Advanced Flask configuration can be achieved through the use of class objects. This approach allows for the creation of distinct configuration sets for different environments, such as development, testing, and production. By defining these configurations as classes, developers can easily switch between them based on the current operational context.
Find elsewhere
🌐
Runebook
runebook.dev › english › articles › flask
Flask Configuration Best Practices: Using Flask.config_class Effectively
Loading Mechanism Review how your application loads configuration values. Make sure your custom config_class interacts correctly with your loading mechanisms. Environment Variables If using environment variables, check that they are set correctly and that your application is reading them properly.
🌐
LinuxTut
linuxtut.com › en › e272ff1aafb3889230bc
Configuration file best practices in Flask
August 31, 2016 - Source version control is essential when developing applications, The configuration file contains passwords, API access keys, etc. There is information that you do not want to include in version control. In Flask, "instance folder" is This is a function to exclude a specific configuration file from version control.
🌐
IT trip
en.ittrip.xyz › python
Mastering Configuration Management in Flask: Best Practices and Tips | IT trip
November 5, 2023 - The key to mastering Flask configuration is to maintain a balance between flexibility, maintainability, and security. By following the outlined practices, you’ll be well on your way to creating robust Flask applications that are easy to manage and scale.
🌐
Readthedocs
flask-dev.readthedocs.io › en › stable › config.html
Configuration Handling — Flask 0.10.1.post20150816 documentation
Applications need some kind of configuration. There are different settings you might want to change depending on the application environment like toggling the debug mode, setting the secret key, and other such environment-specific things. The way Flask is designed usually requires the configuration ...
🌐
Medium
medium.com › thedevproject › how-and-why-have-a-properly-configuration-handling-file-using-flask-1fd925c88f4c
How and why have a properly “Configuration Handling File” using Flask? | by Felipe F Garcia | The Dev Project | Medium
March 30, 2022 - 1 — Initial configuration — That has only the base to start your setup, we will understand how to handle different environments and the connection between for example “environment variables” with your configuration;
🌐
Compile N Run
compilenrun.com › flask tutorial › flask fundamentals › flask configuration
Flask Configuration | Compile N Run
Basic configuration using the app.config dictionary ... By implementing these patterns, you can create Flask applications that are secure, easily configurable, and adaptable to different environments.
🌐
Medium
jnikenoueba.medium.com › the-10-best-practices-for-building-a-flask-application-b5a7dbc784f5
The 10 Best Practices for Building a Flask Application | by Joël-Steve N. | Medium
June 11, 2024 - The 10 Best Practices for Building a Flask Application Flask is a lightweight micro-framework in Python appreciated for its simplicity and flexibility. However, to get the most out of Flask and build …
🌐
Reddit
reddit.com › r/flask › what are the best practices and standard conventions for routes?
r/flask on Reddit: What are the best practices and standard conventions for routes?
March 5, 2024 -

I've inherited the maintenance of a Flask app and there seems to be a lot of inconsistencies around the route syntax convention. In other words the project contains multiple instances of

@app.route(".....") 
@app.get(".....") 
@app.route("....." methods=[POST]) 
@app.post(".....") 

Etc. It's my understanding that

@app.get() == @app.route(methods=[GET]) == @app.route() 

And

@app.post() == @app.route(methods=[POST]) 

Are there subtle differences I am missing, or are these functionally equivalent? Is one method considered standard convention/best practice over another?

Top answer
1 of 2
4
In previous versions of flask, you had to do @app.route(methods=...). Nowadays you can do @app.post etc. They are functionally equivalent. But I recommend you go change all the @app.route to @app.post etc. if you can. The only time you cannot is if it is handling more than one method at once. In that case I would recommend breaking it out into two functions.
2 of 2
2
Like many things, it depends on your app design. app.get, app.post , app.patch, etc are all provided since flask 2 as handy shortcuts, but the original app.route usage is still in the core. For an API, I'd probably use the shortcuts as it improves readability. For a basic web application, I take into account that built in html forms only support get and post. I like to design routes that work for both get AND post. In that case, I use app.route and overload it with the additional methods. If i'm using something like htmx, then I may go with the shortcut methods to improve readability. Personally I'm set in my ways and just like using app.route for copy-paste-ability. But in essence app.get == app.route('/', methods=["GET"]) == app.route('/') since get is the default method and app.post == app.route('/', methods=["POST"]). What I DON'T like seeing is app.get and app.post all used, but then the one-off app.route used when you need mixed-method routes so I just prefer to use app.route. In the end, there aren't standard conventions governing the usage of these and their usage boils down to stylistic choice of the developer and the use cases of the app in question.
🌐
MoldStud
moldstud.com › articles › developers faq › flask developers questions › a beginner's guide to best practices for flask environment variables
A Beginner's Guide to Best Practices for Flask Environment Variables
July 12, 2025 - Production configurations must prioritize security and performance. Set FLASK_ENV=production to disable debug settings, and ensure sensitive information is not exposed to users. Use environment variables for secrets and API keys, which over ...