我正在为个人项目设置我的Flask应用程序,但收到一条错误消息,提示“ TypeError:'Flask'对象不可迭代”
这是我当前的file directory
我还添加了错误消息。
PS C:\Users\jason\Documents\project1> flask run
* Serving Flask app "run.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask_sqlalchemy\__init__.py:835: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
Traceback (most recent call last):
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\jason\AppData\Local\Programs\Python\Python37-32\Scripts\flask.exe\__main__.py", line 9, in <module>
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 906, in main
cli.main(args=args, prog_name=name)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 569, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 779, in run_command
app = DispatchingApp(info.load_app, use_eager_loading=eager_loading)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 300, in __init__
self._load_unlocked()
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 324, in _load_unlocked
self._app = rv = self.loader()
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 381, in load_app
app = locate_app(self, import_name, name)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask\cli.py", line 236, in locate_app
__import__(module_name)
File "C:\Users\jason\Documents\project1\run.py", line 1, in <module>
from app import app
File "C:\Users\jason\Documents\project1\app\__init__.py", line 19, in <module>
Session(app)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\flask\sessions.py", line 79, in __init__
super(SecureCookieSession, self).__init__(initial, on_update)
File "c:\users\jason\appdata\local\programs\python\python37-32\lib\site-packages\werkzeug\datastructures.py", line 2031, in __init__
dict.__init__(self, initial or ())
TypeError: 'Flask' object is not iterable
这是我的奔跑。py
from app import app
if __name__ == '__main__':
app.run(debug=True)
,还有app / init .py
import os
from flask import Flask, Session
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
app = Flask(__name__)
# Setting up secret keys
SECRET_KEY = os.urandom(32)
app.config['SECRET_KEY'] = SECRET_KEY
# Configure session to use filesystem
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://xxxx:yyyy@ec2-some-ip.compute-1.amazonaws.com:5432/zzzzz'
db = SQLAlchemy(app)
Session(app)
from app import routes, form, models
你们在run.py文件和 init .py文件之间看到任何问题吗? 我真的很困惑typeError的意思,因为它没有指出问题的确切出处!