开始Flask项目

Posted 会搓火球的单身gou

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了开始Flask项目相关的知识,希望对你有一定的参考价值。

from flask import Flask ,render_template

app = Flask(__name__)


@app.route(\'/\')
def lx():
    return render_template(\'lx3.html\')
@app.route(\'/login/\',methods=[\'GET\',\'POST\'])
def login():
    return render_template(\'lx2.html\')
@app.route(\'/regist\')
def regist():
    return render_template(\'lx.html\')

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

 

<!DOCTYPE html>

<head>

    <meta charset="UTF-8">

    <title>注册界面</title>
<script src="../static/js/js.js"></script>
</head>

 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet"  type="text/css" href="../static/css/webb.css" >
<base href="www.gzcc.cn"target="_blank">

<nav>
    <ul class="nav nav-tabs">
  <li ><a href="{{url_for(\'lx\')}}">首页</a></li>
  <li><a href="{{url_for(\'login\')}}">登录</a></li>
        <li><a href="{{url_for(\'regist\')}}">注册</a></li>
   <li><input type="text" class="form-control"style="width: 200px" ></li>
    <li><button type="button" class="btn btn-default">搜索</button></li>
    <li ><p align="left"> <img id="myOnOff" onclick="mySwitch()" src="http://www.runoob.com/images/pic_bulbon.gif" width="40px"></p></li>
</ul>

</nav>


<h1>
 注册界面
</h1>


<body  id="myBody" >
<div  class="bigdiv" id="container" >
<div id="header" ><h2 align="center">注册</h2></div>

<div id="content">


    <div align="center"> 账号注册:<input id="user" type="text" name="user" placeholder="请输入用户名" ><br></div>
    <div align="center"> 注册密码:<input  id="upass" type="password" name="password" placeholder="请输入密码"><br></div>
    <div align="center"> 确认密码:<input id="upass1" type="password"name="password" placeholder="请确认密码"></div>
      <div align="center">  <input type="radio" name="role" value="stu">student
      <input type="radio" name="role" value="tea">teacher <br>
      <input type="checkbox" value="true"><span style="color: blueviolet">rember</span> <a href="www.gzcc.cn"> 登陆问题请点</a></div>  <br>

       <div align="center">
            <button onclick="zhuce()">注册</button>
        <input type="button" value="cancel"><br>
       </div>
    <div align="center">
         <div id="error_box"></div><br>
    </div>
</div>
</div>
<footer class="foot">
    <div > <a href="#"> 联系我们</a> · <a href="#"> 加入我们</a> ·  <a href="#"> 品牌与徽标 </a> ·  <a href="#">帮助中心</a> · <a href="#">合作伙伴</a></div>
        <div>©2015-2017 广州商学院信息技术与工程学院 / 粤ICP备278953737号-5 / 粤公网安备2015060050046号 /   Smrz 粤公网安备201506050046号 /   Wxb  举报电话:020-66666666</div>
</footer>
</body>
</html>

 

<!DOCTYPE html>

<head>

    <meta charset="UTF-8">

    <title>登陆界面</title>
<script src="../static/js/js.js"></script>
</head>

 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet"  type="text/css" href="../static/css/webb.css" >

<base href="www.gzcc.cn"target="_blank">

<nav style="background-color: white">

    <ul class="nav nav-tabs">

   <li ><a href="{{url_for(\'lx\')}}">首页</a></li>

  <li><a href="{{url_for(\'login\')}}">登录</a></li>
        <li><a href="{{url_for(\'regist\')}}">注册</a></li>

   <li><input type="text" class="form-control"style="width: 200px" ></li>

        <button type="button" class="btn btn-default">搜索</button>

</ul>

</nav>



<h1>

 用户界面

</h1>


<body class="body">

<p id="demo">这是一个段落</p>
<button type="button" onclick="displayDate()">显示日期</button>

<div  class="bigdiv" id="container" >

<div id="header" ><h2 align="center">登陆</h2></div>

<div id="content">


     <div align="center">username:<input id="user" type="text" name="user" placeholder="请输入用户名" ></div> <br>
       <div align="center"> password:<input  id="upass" type="password" name="password" align="center"><br></div>

      <div align="center">  <input type="radio" name="role" value="stu">student
      <input type="radio" name="role" value="tea">teacher <br>
      <input type="checkbox" value="true"><span style="color: blueviolet">rember</span> <a href="www.gzcc.cn"> 登陆问题请点</a></div>  <br>

       <div align="center">
            <button onclick="fuck()">登录</button>
        <input type="button" value="cancel"><br>
       </div>
    <div align="center">
         <div id="error_box"></div><br>
    </div>
</div>
</div>
</body>
</html>

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <nav style="background-color: white">
    <ul class="nav nav-tabs">
  <li ><a href="{{url_for(\'lx\')}}">首页</a></li>
  <li><a href="{{ url_for(\'login\') }}">登录</a></li><li><a href="{{ url_for(\'regist\') }}">注册</a></li>
   <li><input type="text" class="form-control"style="width: 200px" ></li>
        <button type="button" class="btn btn-default">搜索</button>

</ul>
</nav>
</head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="{{url_for(\'static\',filename=\'css/webb.css\')  }}">

<body class="body">

    <h1 class="h5" >欢迎进入我的网站
    </h1>



</body>
</html>

 

.bigdiv{
    vertical-align: middle;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -200px 0 0 -200px;
    border: 1px solid #ccc;
    width: 400px;
}

.foot{
     position: absolute;
    bottom: 0px;
    margin: 10px;
    width:100%;
    text-align: center;
    color: rgba(58, 40, 66, 0.41);
}
.body{
    background-color: burlywood;
}

 

function mySwitch() {
           var oBody= document.getElementById("myBody");
           var oOnoff=document.getElementById("myOnOff");
           var ogui = document.getElementById("gui");
           if(oOnoff.src.match("bulbon")){
               oOnoff.src="http://www.runoob.com/images/pic_bulboff.gif";
               oBody.style.background="black";
               oBody.style.color="orange";

           }else{oOnoff.src="http://www.runoob.com/images/pic_bulbon.gif";
               oBody.style.background="white";
               oBody.style.color="black";

           }
       }
function zhuce() {
    var oPass =document.getElementById("upass").value;
    var oPass1 =document.getElementById("upass1").value;
    if(oPass!=oPass1){
        document.getElementById("error_box").innerHTML="两次密码输入不一致"
        return;
    }
    window.alert("注册成功")
}

 

 

以上是关于开始Flask项目的主要内容,如果未能解决你的问题,请参考以下文章

开始Flask项目

如何通过单击片段内的线性布局从片段类开始新活动?下面是我的代码,但这不起作用

开始Flask项目

开始Flask项目

开始Flask项目

开始Flask项目