xiaxue0622 2017-01-25 15:41 采纳率: 0%
浏览 10774

python运行html无法实现html页面间的跳转

如题。
用的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ㄒ)/~~

  • 写回答

10条回答

  • 一应常怀 2019-04-25 12:18
    关注

    同问~~~~~~我也是在html中用了a标签,herf = 'xxx.html'单独运行可以跳,但是在flask中就跳不了

    评论

报告相同问题?