烧瓶引导程序路线404

时间:2019-12-18 17:03:29

标签: python html flask

我是flask和boostrap的新手,我试图制作一个链接到另一个html的按钮

项目布局

<div class="container">
    <div class="row">
        <div class="col-md-6 offset-md-3">
            <select (change)="onChange($event.target.value)" class="form-control">

                <option style="color:black" *ngFor="let c of cities" value="{{c.country}}">{{c.country}}</option>
            </select>

        </div>
    </div>
</div>

-Norman -args -static -css -bootstrap.min.css -style.css -img -wall.jpg -templates -index.html -form.html -__init__.py -routes.py -.flaskenv -readme.txt -book.py

route.py:

from args import app # init.py from flask import render_template @app.route('/') def index(): return render_template('index.html') @app.route('/form') def form(): return render_template('form.html')

__init__.py:

这是index.html中的代码:

from flask import Flask
from flask_bootstrap import Bootstrap

app = Flask(__name__)
Bootstrap(app)

from args import routes

im尝试将按钮链接到带有href的open form.html,但是它说在服务器上找不到所请求的url。打开localhost:5000工作,但是第二条路线不工作

1 个答案:

答案 0 :(得分:0)

在您的index.html中:将/form.html替换为/form,因为您已经注册了句柄/form,触发该句柄将呈现form.html

<div>
    <button class="submit-btn">Check availability</button>
    <a href="/form" class="btn btn-primary pull-right" role="button">check form</a>
</div>