Managing project settings from a separate file in Flask

For the configuration file, which at least for now remained here due to all the importing and logic we did, we are going to move it inside imap, click move and therefore it would look like this. Here, I think you can see the structure is a little more logical:

config.py

class Config(object): 
   pass 

class ProdConfig(Config): 
   pass 

class DevConfig(Config): 
   DEBUG = True
   # TESTING = True 

Since here if you need to add other types of configurations, for example if you want to work with walls you need to create an extra file you would create it here for that reason here the root one, the application one, is extremely clean and understandable so here we have it here we are really not doing much and the only thing we have to do is come back here and I will activate this Debug mode:

main.py

from config import DevConfig 
***
app = Flask(__name__) 
app.config.from_object(DevConfig)
***

I was telling you that I don't like it and we can import it here directly now it would be the same as we did before indicating which class we are using so run the application again here it will tell us that the voice mode is active so I take it therefore we could make changes here and it would reload the server so little more to say now with this we also activate the configurations that we made before in our new scheme.

- Andrés Cruz

En español

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.