如题。
用的flask,两个网页index.html和test.html放在templates里,index.py放在根目录下。
index.html下面写了一个跳转:
<a href="../templates/test.html">Switch to baidu</a>
如果单独运行这个index.html的话可以跳转到test.html,
但是如果通过后端的index.py运行的话
index.py:
@app.route('/')
def index():
return render_template('index.html')
能成功进入Index.html,但是从index.html进入test.html的时候就会显示:
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
编译器pycharm里显示:
127.0.0.1 - - [25/Jan/2017 23:24:00] "GET /templates/test.html HTTP/1.1" 404 -
有木有哪位大神哥哥帮忙指导一下/(ㄒoㄒ)/~~
同问~~~~~~我也是在html中用了a标签,herf = 'xxx.html'单独运行可以跳,但是在flask中就跳不了
作者解决了吗 同问
喂喂喂,有人吗
请问解决了吗,我也是同样的问题
在py中加载的时候,页面当前路径有变化了。导致后面获取相对路径文件不正确了
我试了放在哪里都不能跳转
不知道你的问题解决没。直接写href="test"就好了
你把html文件放到static文件夹下,不要放到templates文件夹下。