Wie importiere ich aus der Konfigurationsdatei in Flask?

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie importiere ich aus der Konfigurationsdatei in Flask?

by Anonymous » 08 Mar 2025, 14:17

Ich habe das Layout meines Flask-Projekts von http://blog.miguelgrinberg.com/post/the ... ello-world.

Die folgende Struktur:

Code: Select all

app/
__init__.py
views.py
forms.py
myFile.py
run.py
config.py
< /code>

In Views.py, forms.py Ich kann < /p>

verwendenfrom config import basedir
< /code>

Ich kann das jedoch nicht in myFile.py < /p>

Ich habe < /p>

hinzugefügtimport Flask
< /code>

und wenn ich es [url=viewtopic.php?t=12045]ändern[/url] kann, startet der Flask -Webserver, aber es heißt nicht, dass Änderungen in App /myFile.Py neu gestartet werden.from config import basedir
< /code>

In meiner Python -Datei. Ich sehe nichts Besonderes, das in __init __. py < /code> für forms.py.from flask import Flask
from config import basedir

app = Flask(__name__)
app.config.from_object('config')
from app import views

Top