Flask(1)

from flask import Flask,render_template,request
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)

HOSTNAME='127.0.0.1'
POST='3306'
USERNAME='root'
PASSWORD='root'
DATABASE='movie_mysql'

DB_url='mysql+pymysql://{username}:{password}@{hostname}:{post}/{db}?charset=utf8'.format\
    (username=USERNAME,password=PASSWORD,hostname=HOSTNAME,post=POST,db=DATABASE)

app.config['SQLALCHEMY_DATABASE_URI']=DB_url
app.config['SQLALCHEMY_TRACK_MODIFICATIONS']=False


#链接数据库:
db=SQLAlchemy(app)

class NEWS(db.Model):
    __tablename__ = 'loginer'
    uname = db.Column(db.Integer, primary_key=True)
    pwd = db.Column(db.String(20), nullable=True)
# db.drop_all()
# db.create_all()

@app.route('/')
def hello():
    return render_template("login.html")
@app.route('/login/',methods=['GET','POST'])
def login():
    if request.method=="GET":
        return render_template('login.html')
    if request.method == "POST":
        uname = request.form['zhanghao']
        pwd = request.form['mima']
        news = NEWS.query.filter(NEWS.uname == uname, NEWS.pwd == pwd).all()
        if news:
            return render_template('movie.html')
        else:
            return render_template('login.html')


@app.route('/register/',methods=['GET','POST'])
def register():
    if request.method=="GET":
        return render_template('register.html')
    if request.method=="POST":
        zhanghao=request.form['zhanghao']
        mima=request.form['mima']
        word=NEWS(uname=zhanghao,pwd=mima)
        db.session.add(word)
        db.session.commit()
        return render_template('login.html')
@app.route('/movie/')
def movie():
    return render_template('movie1.html')
@app.route('/movie1/')
def movies1():
    return render_template('movie1.html')

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

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <style>
        body{
            background-image: url("{{ url_for('static',filename='image/1.jpg') }}");
            background-repeat: no-repeat;
            background-size:100%,100%;
        }
        .denglu{
            width: 450px;
           height: 225px;
           position: absolute;
           top:30%;
           left:32%;
           background-color: rgba(170, 170, 255, 0.2);
           border-style: dotted;
           border-radius: 20px;
        }
        .pic{
            width: 200px;
           height: 190px;
           position: absolute;
           left:10px;
           top:30px;
        }
        .pic img{
            width:200px;
            height: 180px;
        }
        .login{
            width: 220px;
           height: 150px;
           color: black;
           position: absolute;
           top: 30%;
           left:50%;
        }
        .login th{
       font-family: "新宋体";
        }
    </style>
</head>
<body>
<div class="denglu">
    <div class="pic">
        <img src="{{ url_for('static',filename='image/2.jpeg') }}" alt="登录图">
    </div>
    <div class="login">
        <form action="/login/" method="post">
    <table>
        <tr>
            <th>登录:</th>
            <th><input type="text" name="zhanghao"></th>
        </tr>
        <tr>
            <th>密码:</th>
            <th><input type="password" name="mima"></th>
        </tr>
        <tr>
            <th><input type="submit" value="登录"></th>
            <th><a href="{{ url_for('register') }}"><input type="button" value="注册"></a></th>
        </tr>
    </table>
    </form>
    </div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>视频播放主界面</title>
    <style>
        body{
            padding: 0;
            margin:0;

        }
        .head{
            position: absolute;
            width: 100%;
            height: 120px;
            background-image: url("{{ url_for('static',filename='image/13.jpg')}}");
            background-repeat: no-repeat;
            background-size: 100%,100%;
            {#background-color: blue;#}
        }
        .all{
            position: absolute;
            top:120px;
            width: 100%;
            height: 700px;

        }
        .foot{
            width: 100%;
            height: 100px;
            background-image: url("{{ url_for('static',filename='image/8.jpg')}}");
            background-repeat: no-repeat;
            background-size: 100%,100%;
            position: absolute;
            top:820px;
        }
        .word{
            position: absolute;
            width: 700px;
            height:120px ;
            {#background-color: chartreuse;#}
        }
        .word h1{
            float: left;
        }
        .word img{
            float:left;
            position: absolute;
            width: 90px;
            height: 90px;
            left:500px;
            top:20px;
        }
        .sou{
            position: absolute;
            left:700px;
            width: 600px;
            height: 120px;
            {#background-color: chartreuse;#}
        }
        .sou ul li{
            list-style: none;
            float: left;
            padding: 5px;
            font-size: 30px;
            font-family: 华文新魏;
        }
        .sou a{
            text-decoration: none;
        }
        .deng{
            position: absolute;
            left:1300px;

        }
        .deng input{
            position: absolute;
            top:60px;
        }
        .deng a{
            text-decoration: none;
        }
        .one{
            position: absolute;
            width: 200px;
            height: 700px;
            background-image: url("{{ url_for("static",filename="image/13.jpg") }}");



        }
        .two{
            position:absolute;
            width:1318px ;
            height: 700px;
            background-image: url("{{ url_for("static",filename="image/8.jpg") }}");
            background-size: 100%,100%;
            left: 200px;
        }
        .one ul li{
            padding: 5px;
            list-style: none;
            font-size: 40px;
            border: blue;
            border-style: double;
            border-radius: 30%;
        }
    </style>

</head>
<body>
    <div class="head">
        <div class="word">
            <h1 style="font-family: 华文彩云 ;text-align: left;position: absolute;left: 200px;font-size: 50px">辣F椒视频</h1>
            <img src="{{ url_for("static",filename="image/11.jpeg") }}" alt="图片">
        </div>
        <div class="sou">
            <ul>
                <li><a href="">今日新闻       |</a></li>
                <li><a href="">今日音乐       |</a></li>
                <li><a href="">今日图片       |</a></li>
            </ul>
        </div>
        <div class="deng">
            <input type="search" value="搜一搜">
            <p style="font-family: 华文琥珀;"><a href="{{ url_for('movies1') }}" >进入个人界面</a></p>
        </div>
    </div>
    <div class="all">
     <div class="one">
         <h2 style="font-family: 幼圆">视频类型</h2>
         <ul>
             <li>军事</li>
             <li>动漫</li>
             <li>音乐</li>
             <li>古风</li>
             <li>其他</li>
         </ul>
     </div>
        <div class="two">
            <video width="400" height="300" controls="controls">
         <source src="{{ url_for("static",filename="movies/2.mp4") }}" type="video/mp4" />
        </video>
         <video width="400" height="300" controls="controls">
         <source src="{{ url_for("static",filename="movies/1.mp4") }}" type="video/mp4" />
        </video>
            <video width="400" height="300" controls="controls">
         <source src="{{ url_for("static",filename="movies/3.mp4") }}" type="video/mp4" />
        </video>
            <video width="400" height="300" controls="controls">
         <source src="{{ url_for("static",filename="movies/4.mp4") }}" type="video/mp4" />
        </video>
            <video width="400" height="300" controls="controls">
         <source src="{{ url_for("static",filename="movies/5.mp4") }}" type="video/mp4" />
        </video>
            <video width="400" height="300" controls="controls">
         <source src="{{ url_for("static",filename="movies/6.mp4") }}" type="video/mp4" />
        </video>
        </div>


    </div>

    <div class="foot">
        <p style="font-family: 隶书;text-align: center;font-size: 40px;color: aliceblue">哈理工课设-王韵通</p>
    </div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人视频界面</title>
    <style>
        body{
            padding: 0;
            margin: 0;
            background-image: url("{{ url_for('static',filename='image/6.jpg') }}");
            background-repeat: no-repeat;
            background-size: 100%,100%;
        }
        .header{
            width: 300px;
            height: 100px;
            position: absolute;
            top:20px;
            left:125px;
        }
        .daohang{
            width:1300px ;
            height: 40px;
            background-image: url("{{ url_for("static",filename="image/2.jpeg") }}");
            position: absolute;
            left:125px;
            top:120px;
            border: blue;
            border-radius: 10px;
        }

        .daohang ul li{
            padding: 0;
            margin: 0;
            float: left;
            height: 80px;
            list-style: none;
            display: inline;
            color: burlywood;
        }
        .daohang ul li a{
            text-decoration: none;
        }
        .one{
            width: 250px;
            height: 200px;
            position: absolute;
            top:170px;
            left:125px;
            background-color: aliceblue;
            border-radius: 10px;
            border-style: solid;
        }
        .two{
            width:250px;
            height:400px;
            position: absolute;
            top:390px;
            left:125px;
            background-color: aliceblue;
            border-radius: 10px;
            border-style: solid;
        }
        .three{
            width:750px;
            height:600px ;
            position: absolute;
            top:170px;
            left: 400px;
            background-color: rgba(170, 170, 255, 0.4);
            border-style: groove;
        }
        .four{
            width:250px;
            height:150px ;
            position: absolute;
            top:170px;
            left: 1175px;
            background-image: url({{ url_for("static",filename="image/6.jpg") }});
            border-radius: 10px;
            border-style: solid;
        }
        .five{
            width:250px;
            height:200px ;
            position: absolute;
            top:340px;
            left: 1175px;
            background-image: url({{ url_for("static",filename="image/9.jpg") }});
            border-radius: 10px;
            border-style: solid;
        }
        .six{
            width:250px;
            height:100px ;
            position: absolute;
            top:560px;
            left: 1175px;
            background-color: aliceblue;
            border-radius: 10px;
            border-style: solid;
        }
        .one img{
            width: 90px;
            height: 120px;
            position: absolute;
            left:120px
        }
        .one p{
            font-family: 华文彩云;
            color: #0000FF;
        }
        .two ul li{
            list-style: none;
            padding: 8px;
            font-size: large;
            border-bottom: dotted 1px;
            font-family: 方正姚体;
        }
        .four ul  li{
            list-style: none;
            border-bottom: 1px;
            border-bottom-style: double;
            color: cornsilk;
        }
        .five ul li{
            list-style: none;
            border-bottom:  1px;
            border-bottom-style: groove;
        }
        .five ul li a{
            text-decoration: none;
        }
    </style>
</head>
<body>
        <div class="header">
            <h1 style="font-family: 华文琥珀">个人视频空间</h1>
            <p>个性签名:欢迎来到我的空间</p>
        </div>
        <div class="daohang">
        <ul>
            <li><a href="">首页>&nbsp;&nbsp;&nbsp;</a></li>
            <li><a href="">信息>&nbsp;&nbsp;&nbsp;</a></li>
            <li><a href="">视频>&nbsp;&nbsp;&nbsp;</a></li>
            <li><a href="">日志>&nbsp;&nbsp;&nbsp;</a></li>
            <li><a href="">帮助>&nbsp;&nbsp;&nbsp;</a></li>
        </ul>
        </div>
        <div class="one">
            <p>个人资料</p>
            <img src="{{ url_for("static",filename="image/7.jpg") }}" alt="个人照片">
            <p>姓名:王某某</p>
            <p>年龄:未知</p>
            <p>性别:男</p>

        </div>
        <div class="two">
            <h2 style="text-align: center;font-family: 方正舒体">历史视频</h2>
            <ul>
                <li>火影忍者</li>
                <li>七龙珠</li>
                <li>海贼王</li>
                <li>圣斗士星矢</li>
                <li>死神</li>
                <li>灌篮高手</li>
            </ul>
        </div>
        <div class="three">
          <video width="400" height="300" controls="controls">
          <source src="{{ url_for("static",filename="movies/7.mp4") }}" type="video/mp4" />
          </video>
        </div>
        <div class="four">
            <h2 style="text-align: center;font-family: 方正舒体">我的好友</h2>
            <ul>
                <li>周杰伦</li>
                <li>林俊杰</li>
                <li>陈奕迅</li>
            </ul>
        </div>
        <div class="five">
            <h2 style="text-align: center;font-family: 方正舒体">友情链接</h2>
            <ul>
                <li><a href="">优酷</a></li>
                <li><a href="">腾讯</a></li>
                <li><a href="">爱奇艺</a></li>
                <li><a href="">B站</a></li>
                <li><a href="">咪咕</a></li>
            </ul>
        </div>
        <div class="six">
            <h5 style="text-align: center">访客记录</h5>
            <p style="font-size: 10px;font-family: 微軟正黑體">总访客量:3000</p>
            <p style="font-size: 10px;font-family: 微軟正黑體">今日访客量:30</p>
        </div>
</body>
</html>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <style>
        body{
             background-image: url("{{ url_for('static',filename='image/5.jpg') }}");
            background-repeat: no-repeat;
            background-size:100%,100%;
        }
        .register{
            width: 300px;
           height: 400px;
           background-color: rgba(170, 170, 255, 0.2);
           position: absolute;
           top:10%;
           left:41%;
           opacity: 0.6;
           border-style: groove;
           border-width: 10px;
        }
        .tex{
            text-align: center;
        }
        .register input{
            position: center;
        }
    </style>
</head>
<body>
<div class="register">
    <div class="tex">
        <p style="font-family: 微軟正黑體">欢迎注册</p>
    </div>
   <div class="zhuce">
        <form action="/register/" method="post">
    <table>
        <tr>
            <th>注册账号:</th>
            <th><input type="text" name="zhanghao"></th>
        </tr>
        <tr>
            <th>注册密码:</th>
            <th><input type="text" name="mima"></th>
        </tr>
        <tr>
            <th>性别:</th>
            <th><input type="radio" name="1">&nbsp; &nbsp;&nbsp; &nbsp;<input type="radio" name="1"></th>
        </tr>
        <tr>
            <th>出生日期:</th>
            <th><input type="date"></th>
        </tr>
        </tr>
        <tr><th>家庭住址:</th>
            <th><select>
                <option>上海</option>
                <option selected="selected">北京</option>
                <option>广州</option>
                <option>深圳</option>
            </select></th>
        </tr>
        <tr>
            <th><br><br><br><br><br><br></th>
            <th><input type="submit" value="提交"></th>
        </tr>
    </table>
</form>
   </div>
</div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值