这是主要架构
wdh/
│
├── app.py
└── templates/
└── index.html
└── home.html
└── static/
└── wdh.jpg
app.py
from flask import Flask, render_template,request
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/login', methods=['POST'])
def login():
name = request.form.get('name')
pwd = request.form.get('password')
if name == 'wdh' and pwd == '123456':
return render_template('index.html')
else:
return render_template('home.html', msg='用户名或者密码错误')
return '收到!'
if __name__ == '__main__':
app.run(host='127.0.0.1', port=8888)
home.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>吴东航的个人主页</title>
</head>
<body>
<h1>登录页面</h1>
<img src="/static/wdh.jpg" width="100px" height="100px">
<label style="color:red">{{msg}}</label>
<form action="/login" method="post">
<label>姓名:</label>
<input type="text" name="name" placeholder="请输入您的大名">
<label>密码:</label>
<input type="password" name="password" placeholder="请输入您的密码,至少6位">
<button type="subumit">点击登录</button>
</form>
</body>
</html>
index.html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>欢迎使用 Flask 微信风格页面</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
margin: 0;
font-family: "Helvetica Neue", sans-serif;
background-color: #f0f0f0;
color: #333;
}
.container {
max-width: 600px;
margin: 50px auto;
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
padding: 40px;
box-sizing: border-box;
}
.logo {
display: block;
margin: 0 auto 20px;
width: 60px;
height: 60px;
background-color: #74c042;
border-radius: 50%;
line-height: 60px;
text-align: center;
color: white;
font-weight: bold;
font-size: 24px;
}
h1 {
text-align: center;
color: #2e2e2e;
margin-bottom: 20px;
}
p {
font-size: 16px;
line-height: 1.6;
text-align: center;
}
.footer {
text-align: center;
margin-top: 40px;
font-size: 14px;
color: #999;
}
</style>
</head>
<body>
<div class="container">
<div class="logo">个人主页</div>
<h1>欢迎使用 Flask</h1>
<p>这是一个模仿微信风格的欢迎页面。你可以继续扩展功能,比如聊天界面、用户登录等。</p>
<video
src="/static/1.1数字三角形模型.mp4"
controls
loop
preload="auto"
style="width: 100%; max-width: 800px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);">
您的浏览器不支持 video 标签。
</video>
</div>
<div class="footer">
© 2025 Flask 微信风格示例
</div>
</body>
</html>
视频控制标签使用
<video
src="/static/111.mp4"
controls
autoplay
muted
loop
preload="auto"
style="width: 100%; max-width: 800px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);">
您的浏览器不支持 video 标签。
</video>
—— 本文来自火龙信奥(义乌睿码科技):义乌青少年信息学奥赛与编程教育平台,专注 CSP-J/S、NOIP、GESP 竞赛培训,线上线下融合教学,助力编程升学。网址:hlcoding.com