码迷,mamicode.com
首页 > 其他好文 > 详细

开始Flask项目

时间:2017-11-03 21:48:41      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:ref   技术分享   input   idt   ati   通过   clear   密码   sel   

新建Flask项目。

设置调试模式。

理解Flask项目主程序。

使用装饰器,设置路径与函数之间的关系。

使用Flask中render_template,用不同的路径,返回首页、登录员、注册页。

用视图函数反转得到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>MIS15</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>MIS问答平台</h1>
<h4>2015</h4>
<P></P>

<div  id="container" style="width:400px " >
    <div id="header" style="background-color:#97ceff;"><h2 align="center" style="margin-bottom:0;">登录</h2></div>
    <form>
        <input type="text" name="usertname"placeholder="请输入用户名"><br>
        <input type="password" name="password"placeholder="请输入六位数密码"><br>
        <input type="radio" name="role" value="stu">student
         <input type="radio" name="role" value="stu">teather<br>
        <input type="button" value="确定">
    </form>
    <div id="footer" style="background-color:#ffa7d7;clear:both;text-align:center;">版权 ? yan</div>

<form>
    <select>
        <option>问答</option>
        <option>收藏</option>
    </select>
</form>

    <ol>
        <li>python</li>
        <li>html</li>
    </ol>

</div>
<hr>
<p>友情链接</p>
<a href="http://www.gzcc.cn/">
    <img src="http://www.gzcc.cn/2016/images/banner.png" width="400" height="50" alt="gzcc.cn"  />
    <br>广州商学院
</a>

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

</head>
<body>
<div class="box">
<h2>欢迎进入</h2>
<h3>VIP Register</h3>

<div class="input_box">
            请输入邮箱   <input id="email" type="text" placeholder="需要通过邮件激活账户">  </div><br>
        <div class="input_box">
            请输入账号 <input id="uname" type="text" placeholder="请输入你的昵称">   </div><br>
        <div class="input_box">
            请输入密码 <input id="upass" type="password" placeholder="请输入密码"></div><br>
         <div class="input_box">
            再输入密码 <input id="upass1" type="password" placeholder="第二次输入密码"></div><br>
        <div id="error_box"><br></div>
         <div class="input_box">
            <button onclick="fnLogin()" >注册</button></div>
</div>
</body>
</html>

技术分享技术分享技术分享

 

开始Flask项目

标签:ref   技术分享   input   idt   ati   通过   clear   密码   sel   

原文地址:http://www.cnblogs.com/xy223/p/7780388.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!