flask dev服务器正在附加子类别url,导致404错误。你知道吗
这是我的网址结构。。。你知道吗
/services
/services/marketing/inbound
/services/marketing/outbound
我的期望是,如果我按照这个顺序航行,它们都会解决。但是,/service url正在由/service追加,如下所示。。。。你知道吗
GET / HTTP/1.1" 200
GET /about HTTP/1.1" 200
GET /faq HTTP/1.1" 200
GET /contact HTTP/1.1" 200
GET /services/marketing HTTP/1.1" 200
GET /services/services/marketing/inbound HTTP/1.1" 404
GET /services/services/marketing/outbound HTTP/1.1" 404
查看
@app.route('/<path:path>')
def page(path):
t = Tree(path)
pg = t.get_page() # return Page model object
bc = t.build_path() # returns bread-crumbs list ['/', 'services']
mn = t.get_children() # returns sub-menu list ['inbound', 'out-bound']
return render_template('page.html', pg=pg, bc=bc, mn=mn)
模板
<a href="services/medical-billing-quality-control">Billing Quality Control</a>
我也尝试过这个,但它也会导致一个URL构建错误。你知道吗
<a href="{{ url_for('marketing', path=services) }}">Billing Quality Control</a>
werkzeug.routing.BuildError: ('medical-collections',
{'path': 'services'}, None)
在您的URL中
href="services/etc"
应该是href="/services/etc"
(注意前面的斜杠)。否则,href
被解释为相对于当前路径的资源路径,这不是您想要的。你知道吗相关问题 更多 >
编程相关推荐