开始Flask项目

开始Flask项目

  1. 新建Flask项目。
  2. 设置调试模式。
  3. 理解Flask项目主程序。
  4. 使用装饰器,设置路径与函数之间的关系。
  5. 使用Flask中render_template,用不同的路径,返回首页、登录员、注册页。
  6. 用视图函数反转得到URL,{{url_for(‘login’)}},完成导航条里的链接。
from flask import Flask,render_template

app = Flask(__name__)


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

@app.route('/login/')
def login():
    return render_template('login.html')

@app.route('/regist/')
def regist():
    return render_template('regist.html')

if __name__ == '__main__':
    app.run(debug=True)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>
<a href="http://127.0.0.1:5000">首页</a>
<a href="http://127.0.0.1:5000/login">登录</a>
<a href="{{ url_for('regist') }}">注册</a>

<h1>首页</h1>

</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>登录</title>
  <link href="../static/css/denglu.css" rel="stylesheet" type="text/css">
  <script src="../static/js/denglu.js"></script>

</head>

<body>


<form method="post" action="index.html">
<div class="box">
<h1>用户登录</h1>
<div class="input_box1">
     <input id="uname" type="text" placeholder="请输入用户名">
 </div>
 <div class="input_box2">
    <input id="upass" type="password" placeholder="请输入密码">
        </div>
        <div id="error_box"><br></div>
   <div class="input_box">
       <button onclick="fnlogin()">登录</button>
   </div>


</div>

</form>

</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>注册</title>
  <link href="../static/css/denglu.css" rel="stylesheet" type="text/css">
  <script src="../static/js/denglu.js"></script>

</head>

<body>


<form method="post" action="index.html">
<div class="box">
<h1>注册</h1>
<div class="input_box1">
     <input id="uname" type="text" placeholder="请输入用户名">
 </div>
 <div class="input_box2">
    <input id="upass" type="password" placeholder="请输入密码">
     <input id="upass1" type="password" placeholder="请确认密码">
        </div>
        <div id="error_box"><br></div>
   <div class="input_box">
       <button onclick="fnlogin()">登录</button>
   </div>

</div>

</form>

</body>
</html>

 

posted @ 2017-11-03 20:10 林丹宜 阅读( ...) 评论( ...) 编辑 收藏
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值