docs: 2026-04-28作业
This commit is contained in:
32
2026-04-28/2026-04-28_hw_1.py
Normal file
32
2026-04-28/2026-04-28_hw_1.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
from flask import Flask, render_template
|
||||||
|
from flask import flash, redirect, session, request, url_for
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.secret_key = 'Your_secret_key&^52@!' # 设置secret_key
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/home')
|
||||||
|
@app.route('/')
|
||||||
|
def home_page():
|
||||||
|
username = session.get('username')
|
||||||
|
# 判断session是否存储username的数据
|
||||||
|
if 'username' in session:
|
||||||
|
return render_template('hw_t1_home_page.html', username=username)
|
||||||
|
return redirect(url_for('login')) # 重定向到login页面
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
|
def login():
|
||||||
|
if request.method == 'POST':
|
||||||
|
if request.form['username'] != 'admin' or \
|
||||||
|
request.form['password'] != '123':
|
||||||
|
flash('用户名或密码错误', category='error')
|
||||||
|
else:
|
||||||
|
session['username'] = request.form['username']
|
||||||
|
session['password'] = request.form['password']
|
||||||
|
flash('恭喜您,登录成功', category='info')
|
||||||
|
return redirect(url_for('home_page'))
|
||||||
|
return render_template('hw_t1_login.html')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(port=80)
|
||||||
13
2026-04-28/2026-04-28_hw_2.py
Normal file
13
2026-04-28/2026-04-28_hw_2.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from flask import *
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
@app.route('/static-file')
|
||||||
|
def load_staticfile():
|
||||||
|
return render_template('hw_t2.html')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app.run(port=80)
|
||||||
BIN
2026-04-28/24计应1_杨近澜_1113_2026-04-28作业.docx
Normal file
BIN
2026-04-28/24计应1_杨近澜_1113_2026-04-28作业.docx
Normal file
Binary file not shown.
BIN
2026-04-28/static/flask.png
Normal file
BIN
2026-04-28/static/flask.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
15
2026-04-28/templates/hw_t1_home_page.html
Normal file
15
2026-04-28/templates/hw_t1_home_page.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>3</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>主页</h2>
|
||||||
|
{% for message in get_flashed_messages(category_filter = ('info')) %}
|
||||||
|
<span>{{ message }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
<p>欢迎用户:{{ username }}</p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
21
2026-04-28/templates/hw_t1_login.html
Normal file
21
2026-04-28/templates/hw_t1_login.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>用户登录</h2>
|
||||||
|
{% for message in get_flashed_messages(category_filter = ('error')) %}
|
||||||
|
<p class="error" style="color: red;">{{ message }}</p>
|
||||||
|
{% endfor %}
|
||||||
|
<form action="" method="post" class="form">
|
||||||
|
<span>用户名:</span><br>
|
||||||
|
<input type="text" name="username"><br>
|
||||||
|
<span>密码:</span><br>
|
||||||
|
<input type="password" name="password"><br>
|
||||||
|
<p><input type="submit" value="登录"></p>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
180
2026-04-28/templates/hw_t2.html
Normal file
180
2026-04-28/templates/hw_t2.html
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>hw</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: linear-gradient(45deg, #0f0c29, #302b63, #24243e, #1c1c3c, #0f0c29);
|
||||||
|
background-size: 400% 400%;
|
||||||
|
animation: gradientBG 10s ease infinite;
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes gradientBG {
|
||||||
|
0% { background-position: 0% 50%; }
|
||||||
|
50% { background-position: 100% 50%; }
|
||||||
|
100% { background-position: 0% 50%; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 浮动粒子 */
|
||||||
|
.particle {
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
animation: floatUp linear infinite;
|
||||||
|
bottom: -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes floatUp {
|
||||||
|
0% { transform: translateY(0) scale(1); opacity: 0; }
|
||||||
|
10% { opacity: 0.6; }
|
||||||
|
90% { opacity: 0.6; }
|
||||||
|
100% { transform: translateY(-110vh) scale(0.5); opacity: 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
position: relative;
|
||||||
|
z-index: 10;
|
||||||
|
text-align: center;
|
||||||
|
padding: 50px 60px;
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
border-radius: 24px;
|
||||||
|
backdrop-filter: blur(16px);
|
||||||
|
-webkit-backdrop-filter: blur(16px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||||
|
box-shadow:
|
||||||
|
0 8px 32px rgba(0, 0, 0, 0.3),
|
||||||
|
0 0 60px rgba(100, 200, 255, 0.1);
|
||||||
|
transition: transform 0.4s ease, box-shadow 0.4s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card:hover {
|
||||||
|
transform: translateY(-10px) scale(1.02);
|
||||||
|
box-shadow:
|
||||||
|
0 20px 60px rgba(0, 0, 0, 0.4),
|
||||||
|
0 0 80px rgba(100, 200, 255, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
font-weight: 900;
|
||||||
|
letter-spacing: 4px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: #fff;
|
||||||
|
text-shadow:
|
||||||
|
0 0 10px rgba(0, 255, 255, 0.8),
|
||||||
|
0 0 20px rgba(0, 255, 255, 0.6),
|
||||||
|
0 0 40px rgba(0, 255, 255, 0.4),
|
||||||
|
0 0 80px rgba(0, 255, 255, 0.2);
|
||||||
|
animation: flicker 3s infinite alternate;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes flicker {
|
||||||
|
0%, 18%, 22%, 25%, 53%, 57%, 100% {
|
||||||
|
text-shadow:
|
||||||
|
0 0 10px rgba(0, 255, 255, 0.8),
|
||||||
|
0 0 20px rgba(0, 255, 255, 0.6),
|
||||||
|
0 0 40px rgba(0, 255, 255, 0.4),
|
||||||
|
0 0 80px rgba(0, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
20%, 24%, 55% {
|
||||||
|
text-shadow:
|
||||||
|
0 0 5px rgba(0, 255, 255, 0.5),
|
||||||
|
0 0 10px rgba(0, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.img-wrapper {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 6px;
|
||||||
|
background: linear-gradient(45deg, #00f260, #0575e6, #ff00cc, #333399);
|
||||||
|
background-size: 300% 300%;
|
||||||
|
animation: borderMove 4s linear infinite;
|
||||||
|
box-shadow: 0 0 30px rgba(0, 200, 255, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes borderMove {
|
||||||
|
0% { background-position: 0% 50%; }
|
||||||
|
50% { background-position: 100% 50%; }
|
||||||
|
100% { background-position: 0% 50%; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.img-wrapper img {
|
||||||
|
display: block;
|
||||||
|
max-width: 300px;
|
||||||
|
border-radius: 16px;
|
||||||
|
transition: transform 0.5s ease, filter 0.5s ease;
|
||||||
|
filter: brightness(1.1) contrast(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.img-wrapper:hover img {
|
||||||
|
transform: scale(1.08) rotate(2deg);
|
||||||
|
filter: brightness(1.2) contrast(1.2) saturate(1.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 扫描线效果 */
|
||||||
|
.scanline {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(
|
||||||
|
to bottom,
|
||||||
|
rgba(255,255,255,0),
|
||||||
|
rgba(255,255,255,0) 50%,
|
||||||
|
rgba(0,0,0,0.05) 50%,
|
||||||
|
rgba(0,0,0,0.05)
|
||||||
|
);
|
||||||
|
background-size: 100% 4px;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 999;
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- 浮动粒子 -->
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
for (let i = 0; i < 30; i++) {
|
||||||
|
const p = document.createElement('div');
|
||||||
|
p.className = 'particle';
|
||||||
|
const size = Math.random() * 6 + 2;
|
||||||
|
p.style.width = size + 'px';
|
||||||
|
p.style.height = size + 'px';
|
||||||
|
p.style.left = Math.random() * 100 + 'vw';
|
||||||
|
p.style.animationDuration = (Math.random() * 8 + 4) + 's';
|
||||||
|
p.style.animationDelay = (Math.random() * 5) + 's';
|
||||||
|
document.body.appendChild(p);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="scanline"></div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<p>Flask-Logo图片</p>
|
||||||
|
<div class="img-wrapper">
|
||||||
|
<img src="{{ url_for('static',filename='flask.png') }}" alt="Flask Logo">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user