html 带表单参数的简单注册页面(包括404页面处理)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 带表单参数的简单注册页面(包括404页面处理)相关的知识,希望对你有一定的参考价值。

from flask import Flask, render_template, request
app = Flask(__name__)

@app.route('/')
def index():
    return render_template('06-index.html')

@app.route('/signup')
def signup_form():
    return render_template('06-Sign-up.html')

@app.route('/thankyou')
def thank_you():
    first = request.args.get('first')
    last = request.args.get('last')
    return render_template('06-thankyou.html', first=first, last=last)

@app.errorhandler(404)
def page_not_found(e):
    return render_template('06-404.html'), 404

if __name__ == '__main__':
    app.run(debug=True)

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Puppy Rock</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </head>
  <body>
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <a class="navbar-brand" href="{{url_for('index')}}">Home Page</a>
    </nav>
    {% block content %}
    {% endblock %}
  </body>
</html>
{% extends "06-base.html"%}
{% block content %}
<div class="jumbotron">
<p>Welcome to Puppy Rock!</p>
<p>Wanna sign up for our puppy band?</p>
<a href="{{url_for('signup_form')}}">Sign up for auditions here</a>
</div>
{% endblock %}
{% extends "06-base.html"%}
{% block content %}
<div class="jumbotron">


<h1>Welcome to the sign up page!</h1>
<p>We're excited to have you audition for our band</p>
<p>This will redirect to a thank you page.</p>
<p>
  Please note, we're just puppies, so we haven't
  learned how to save your information yet!
</p>
    <form action="{{url_for('thank_you')}}">
       <label for="first">First Name</label>
        <input type="text" name="first">
        <label for="last">Last Name</label>
        <input type="text" name="last">
        <input type="submit" value="Submit Form">
    </form>

</div>
{% endblock %}
{% extends "06-base.html"%}
{% block content %}
<div class="jumbotron">

  <h1>Thank you for signing up {{first}} {{last}}!</h1>
</div>
{% endblock %}
{% extends "06-base.html"%}
{% block content %}
<div class="jumbotron">
<p>Sorry, we couldn't find the page you were looking for.</p>
<p>Cut us some slack, we're just puppies!</p>
</div>
{% endblock %}

以上是关于html 带表单参数的简单注册页面(包括404页面处理)的主要内容,如果未能解决你的问题,请参考以下文章

Laravel 5.2 在同一页面上登录和注册表单

yii2 表单提交一直报错 或者页面脚本写ajax,用firbug调试总是找不到地址页面404

不同页面之间实现参数传递的几种方式

使用HTML、CSS和JS制作一个论坛注册页面(使用表格布局),符合以下要求 1、注册信息包括注册名、密码、性别

在 Django 中使用纯 HTML 页面进行注册

关于不同页面之间实现参数传递的几种方式讨论