Python 找不到烧瓶蓝图url
我正在尝试使用蓝图创建一个flask应用程序,因此我有以下结构:Python 找不到烧瓶蓝图url,python,flask,Python,Flask,我正在尝试使用蓝图创建一个flask应用程序,因此我有以下结构: myapp/ __init__.py static/ templates/ site/ index.html register.html layout.html views/ __init__.py site.py models.py \uuuu init\uuuuu.py fr
myapp/
__init__.py
static/
templates/
site/
index.html
register.html
layout.html
views/
__init__.py
site.py
models.py
\uuuu init\uuuuu.py
from flask import Flask
from .views.site import site
app = Flask(__name__)
app.register_blueprint(site)
from flask import Blueprint, render_template
site = Blueprint('site', __name__)
site.route('/')
def index():
return render_template('site/index.html')
site.route('/register/')
def register():
return render_template('site/register.html')
视图/site.py
from flask import Flask
from .views.site import site
app = Flask(__name__)
app.register_blueprint(site)
from flask import Blueprint, render_template
site = Blueprint('site', __name__)
site.route('/')
def index():
return render_template('site/index.html')
site.route('/register/')
def register():
return render_template('site/register.html')
当我运行应用程序,并尝试进入我拥有的任何路线时,我唯一能感觉到的是“404未找到”,我真的不知道我做错了什么,因为我正在做这本书所说的:
提前感谢。您必须预先将
@
发送到站点。按如下方式发送
from flask import Blueprint, render_template
site = Blueprint('site', __name__)
@site.route('/')
def index():
return render_template('site/index.html')
@site.route('/register/')
def register():
return render_template('site/register.html')
您必须预先将@
发送到站点。按如下方式发送
from flask import Blueprint, render_template
site = Blueprint('site', __name__)
@site.route('/')
def index():
return render_template('site/index.html')
@site.route('/register/')
def register():
return render_template('site/register.html')
您正试图访问的URL是什么?@jobou当我执行它时,例如:“127.0.0.1:5000/注册”,或者仅仅是简单的主页“127.0.0.1:5000”您正试图访问的URL是什么?@jobou当我执行它时,例如:“127.0.0.1:5000/注册”,或者仅仅是简单的主页“127.0.0.1:5000”:)很好。当我检查代码时,它并没有对我突出。哦!看在上帝的份上!!!我太困了,太累了,忘了是装修工干的。当我检查代码时,它并没有对我突出。哦!看在上帝的份上!!!我太困了,太累了,忘了是装修工。