我正在开发一个应用程序,它的结构看起来与
facebook/
__init__.py
feed/
__init__.py
models.py
business.py
views.py
chat/
__init__.py
models.py
business.py
views.py
我facebook.__init__.py
的是
from flask import Flask
app = Flask(__name__)
import feed.views
import chat.views
我facebook.runserver.py
的是
from . import app
app.run(debug=True)
我feed.views.py
的是
from .. import app
@app.route('/hello')
def hello():
return 'hello world'
我chat.views.py
的是
from .. import app
@app.route('/chat')
def chat():
return 'Let's chat'
当我尝试运行此应用程序时python runserver.py
,我看到错误为
Traceback (most recent call last):
File "facebook/runserver.py", line 1, in <module>
from . import app
ValueError: Attempted relative import in non-package
我该如何解决?