F
F
Freerade2022-04-21 17:18:19
Flask
Freerade, 2022-04-21 17:18:19

Why change config in flask when you can just write the path right away?

DATABASE = '/tmp/flsite.db'
DEBUG = True
SECRET_KEY = 'fsdfafxf34gfdgsf>dsa,faff'

app = Flask(__name__)
app.config.from_object(__name__)

app.config.update(dict(DATABASE=os.path.join(app.root_path, 'flsite')))


I study flask and the following points are not clear
1. Why write what is tmp in this case? It seems that just the path should be written, I don’t have a tmp folder in the project, why is it?
2. app.root_path changes the path to the working directory, as I understand it, but why is this needed if you can immediately register it in DATABASE?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Griboks, 2022-04-21
@Griboks

Why write what is tmp in this case? It seems that just the path should be written, I don’t have a tmp folder in the project, why is it?

Just a standard project template. If you don't need it, don't write.
app.root_path changes the path to the working directory, as I understand it, but why is this needed if you can immediately register it in DATABASE?

If the root path changes, you will have to rewrite the source code. And so you can automatically use the actual path.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question