내 프로젝트 구조는이 mysite.conf.__init__
플라스크
from flask import Flask
app = Flask(__name__)
app.debug = True
내 생각은 이제 뷰를 생성하는 데 사용하는 다른 모든 모듈에 app
를 가져올입니다
run.py
lib/
mysite/
conf/
__init__.py (flask app)
settings.py
pages/
templates/
index.html
views.py
__init__.py
이하 같다. 여기에는이 경우 모듈
pages
이 있습니다.
pages.views
에서
나는
from mysite.conf import app
app.run()
아래 내가 갖는 같습니다 run.py
에서이 응용 프로그램을 실행하면
from flask import render_template
from mysite.conf import app
@app.route('/')
def index():
return render_template('index.html')
index.html
같은 일부 코드가 pages/templates
에 배치되어 있습니다 템플릿을 찾을 수 없습니다. 어떻게 고칠 수 있습니까? 왜 이런 일이 일어나는가!
기본적으로 나는 장고 사람이고, 모든 모듈에서보기를 생성 할 때마다 wsgi
객체를 가져올 때 많은 불편을 겪습니다. 다소 미친 듯이 느껴진다. 어떤면에서 순환 수입을 장려한다. 이것을 피할 수있는 방법이 있습니까?
Try'render_template ('templates/index.html')' – ajkumar25