Compare commits
11 Commits
0a9c136d90
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 546f231698 | |||
| 8dd1fae2e1 | |||
| 6b51126213 | |||
| dd21ddbaef | |||
| b0db5b3239 | |||
| af13f500e1 | |||
| 2ae54f2f06 | |||
| 5dcc0fcada | |||
| 243711134c | |||
| 8fc93fcc0e | |||
| 8f86474ad7 |
10
.idea/.gitignore
generated
vendored
Normal file
10
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 已忽略包含查询文件的默认文件夹
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.14" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/myPythonWebHomework.iml" filepath="$PROJECT_DIR$/.idea/myPythonWebHomework.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/myPythonWebHomework.iml
generated
Normal file
8
.idea/myPythonWebHomework.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.14" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
7
2026-03-10/c1.py
Normal file
7
2026-03-10/c1.py
Normal file
@@ -0,0 +1,7 @@
|
||||
code = """code = "__code__"
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")"""
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")
|
||||
7
2026-03-10/c2.py
Normal file
7
2026-03-10/c2.py
Normal file
@@ -0,0 +1,7 @@
|
||||
code = """code = "__code__"
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")"""
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")
|
||||
7
2026-03-10/c3.py
Normal file
7
2026-03-10/c3.py
Normal file
@@ -0,0 +1,7 @@
|
||||
code = """code = "__code__"
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")"""
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")
|
||||
7
2026-03-10/c4.py
Normal file
7
2026-03-10/c4.py
Normal file
@@ -0,0 +1,7 @@
|
||||
code = """code = "__code__"
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")"""
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")
|
||||
7
2026-03-10/c5.py
Normal file
7
2026-03-10/c5.py
Normal file
@@ -0,0 +1,7 @@
|
||||
code = """code = "__code__"
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")"""
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")
|
||||
7
2026-03-10/mypython22.py
Normal file
7
2026-03-10/mypython22.py
Normal file
@@ -0,0 +1,7 @@
|
||||
code = """code = "__code__"
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")"""
|
||||
ref = '"'
|
||||
sign = "__" + "code" + "__"
|
||||
print(code.replace(sign, ref + ref + code + ref + ref), end="")
|
||||
8
2026-03-17/2026-03-17_hw_1.py
Normal file
8
2026-03-17/2026-03-17_hw_1.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# 判断整数是否是回文数
|
||||
|
||||
n = int(input("请输入整数: "))
|
||||
sn = str(n)
|
||||
if sn == sn[::-1]:
|
||||
print("输入的是回文数")
|
||||
else:
|
||||
print("输入的不是回文数")
|
||||
18
2026-03-17/2026-03-17_hw_2.py
Normal file
18
2026-03-17/2026-03-17_hw_2.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# 物流计费系统
|
||||
|
||||
d = {"01": (13, 3), "02": (12, 2), "03": [14, 4]}
|
||||
area = input("请输入地区编号: ")
|
||||
weight = 0
|
||||
while True:
|
||||
try:
|
||||
weight = int(input("请输入重量(kg): "))
|
||||
break
|
||||
except ValueError:
|
||||
print("请输入整数...")
|
||||
if area not in d:
|
||||
print("地区编号不正确,请输入正确的地区编号")
|
||||
else:
|
||||
(p1, p2) = d[area]
|
||||
if weight < 2:
|
||||
weight = 2
|
||||
print("价格是: " + str(p1 + (weight - 2) * p2))
|
||||
7
2026-03-17/2026-03-17_hw_3.py
Normal file
7
2026-03-17/2026-03-17_hw_3.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# 九九乘法表
|
||||
|
||||
n = 9
|
||||
for i in range(1, n + 1):
|
||||
for j in range(1, i + 1):
|
||||
print(j, '*', i, '=', i * j, sep=" ", end="\t")
|
||||
print()
|
||||
BIN
2026-03-17/24计应1_杨近澜_1113_2026-03-17作业.docx
Normal file
BIN
2026-03-17/24计应1_杨近澜_1113_2026-03-17作业.docx
Normal file
Binary file not shown.
28
2026-03-24/2026-03-24_hw_1.py
Normal file
28
2026-03-24/2026-03-24_hw_1.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# 实现简单的四则运算计算器
|
||||
# 输入两个数一个运算符,输出结果
|
||||
|
||||
|
||||
def add(num1:float, num2:float) -> float:
|
||||
return num1 + num2
|
||||
def sub(num1:float, num2:float) -> float:
|
||||
return num1 - num2
|
||||
def mul(num1:float, num2:float) -> float:
|
||||
return num1 * num2
|
||||
def div(num1:float, num2:float) -> float:
|
||||
return num1 / num2
|
||||
|
||||
def main():
|
||||
a1 = float(input("请输入第一个数: "))
|
||||
a2 = float(input("请输入第二个数: "))
|
||||
s = input("请输入运算符: ")
|
||||
|
||||
if s not in ["+", "-", "*", "/"]:
|
||||
print("请输入正确的符号")
|
||||
return
|
||||
|
||||
p = {"+": add, "-": sub, "*": mul, "/": div}
|
||||
print(p[s](a1, a2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
61
2026-03-24/2026-03-24_hw_2.py
Normal file
61
2026-03-24/2026-03-24_hw_2.py
Normal file
@@ -0,0 +1,61 @@
|
||||
# 入机猜拳
|
||||
|
||||
|
||||
import random
|
||||
|
||||
class Player:
|
||||
def __init__(self):
|
||||
self.dict_gesture = {0: '剪刀', 1: '石头', 2: '布'}
|
||||
|
||||
def gesture(self, num):
|
||||
return self.dict_gesture[num]
|
||||
|
||||
class AIPlayer(Player):
|
||||
play_data = [] # 存储玩家猜拳手势(类属性)
|
||||
|
||||
def ai_gesture(self):
|
||||
while True:
|
||||
computer = random.randint(0, 2)
|
||||
if len(self.play_data) >= 4:
|
||||
# 获取玩家出拳的最大概率
|
||||
max_prob = max(self.play_data, key=self.play_data.count)
|
||||
if max_prob == '剪刀':
|
||||
return '石头'
|
||||
elif max_prob == '石头':
|
||||
return '布'
|
||||
else:
|
||||
return '剪刀'
|
||||
else:
|
||||
return self.dict_gesture[computer]
|
||||
|
||||
class Game(Player):
|
||||
def game_judge(self):
|
||||
player_num = int(input("请输入(0剪刀、1石头、2布:)")) # 玩家输入的手势
|
||||
player = self.gesture(player_num)
|
||||
AIPlayer().play_data.append(player)
|
||||
ai_player = AIPlayer().ai_gesture()
|
||||
|
||||
if (player == '剪刀' and ai_player == '布') or \
|
||||
(player == '石头' and ai_player == '剪刀') or \
|
||||
(player == '布' and ai_player == '石头'):
|
||||
print(f"电脑出的手势是{ai_player},恭喜,你赢了!")
|
||||
elif (player == '剪刀' and ai_player == '剪刀') or \
|
||||
(player == '石头' and ai_player == '石头') or \
|
||||
(player == '布' and ai_player == '布'):
|
||||
print(f"电脑出的手势是{ai_player},打成平局了!")
|
||||
else:
|
||||
print(f"电脑出的手势是{ai_player},你输了,再接再厉!")
|
||||
|
||||
def main(self):
|
||||
self.game_judge()
|
||||
while True:
|
||||
option = input("是否继续:y/n\n")
|
||||
if option == 'y':
|
||||
self.game_judge()
|
||||
else:
|
||||
break
|
||||
|
||||
# 程序入口
|
||||
if __name__ == "__main__":
|
||||
game = Game()
|
||||
game.main()
|
||||
28
2026-03-24/2026-03-24_hw_3.py
Normal file
28
2026-03-24/2026-03-24_hw_3.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# 实现 Circle 类...
|
||||
|
||||
|
||||
import math
|
||||
|
||||
class Circle():
|
||||
radius = float(0)
|
||||
def __init__(self, radius:float) -> None:
|
||||
self.radius = radius
|
||||
|
||||
def get_peimeter(self) -> float:
|
||||
return math.pi * self.radius * 2
|
||||
|
||||
def get_area(self) -> float:
|
||||
return math.pi * (self.radius ** 2)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"radius: {self.radius}\npeimeter: {self.get_peimeter()}\narea: {self.get_area()}\n"
|
||||
|
||||
def main() -> int:
|
||||
cir1 = Circle(3.0)
|
||||
# print(str(cir1))
|
||||
print(f"cir1: peimeter: {cir1.get_peimeter()}")
|
||||
print(f"cir1: narea: {cir1.get_area()}")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
2026-03-24/24计应1_杨近澜_1113_2026-03-24作业.docx
Normal file
BIN
2026-03-24/24计应1_杨近澜_1113_2026-03-24作业.docx
Normal file
Binary file not shown.
16
2026-04-07/2026-04-07_hw_1.py
Normal file
16
2026-04-07/2026-04-07_hw_1.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from flask import Flask
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/liuhz1/")
|
||||
def lhz():
|
||||
return "哇! 你找到lhz啦! "
|
||||
|
||||
app.add_url_rule(rule = "/liuhz2/", view_func= lhz)
|
||||
|
||||
def main():
|
||||
app.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
BIN
2026-04-07/24计应1_杨近澜_1113_2026-04-07作业.docx
Normal file
BIN
2026-04-07/24计应1_杨近澜_1113_2026-04-07作业.docx
Normal file
Binary file not shown.
36
2026-04-07/main.py
Normal file
36
2026-04-07/main.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from flask import Flask
|
||||
from werkzeug.routing import BaseConverter
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
@app.route("/")
|
||||
def hello_flask():
|
||||
return "<p>Hello, Flask!</p>"
|
||||
|
||||
@app.route("/index/")
|
||||
def index():
|
||||
return "<h1>这是首页!</h1>"
|
||||
|
||||
@app.route("/api/lhz/")
|
||||
def lhz():
|
||||
return """ <div>这是LiuHanZheng</div>
|
||||
<div>Length: 1cm</div>"""
|
||||
|
||||
app.add_url_rule(rule='/lhz/', view_func=lhz)
|
||||
|
||||
@app.route("/pages/<int:page>/")
|
||||
def page_num(page):
|
||||
return f"<div>当前为第{page}页</div>"
|
||||
|
||||
|
||||
class MobileConverter(BaseConverter): # 自定义转换器
|
||||
regex = "1[3-9]\d{9}$" # 定义匹配手机号码的规则
|
||||
app.url_map.converters["mobile"] = MobileConverter # 添加到转换器字典
|
||||
|
||||
@app.route("/user/<mobile:mobile>/")
|
||||
def mobile_index(mobile):
|
||||
return f'手机号为:{mobile}'
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(port=1145)
|
||||
BIN
2026-04-07/requirements.txt
Normal file
BIN
2026-04-07/requirements.txt
Normal file
Binary file not shown.
32
2026-04-14/2026-04-14_hw_1.py
Normal file
32
2026-04-14/2026-04-14_hw_1.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from flask import Flask, after_this_request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.before_first_request
|
||||
def before_first_request():
|
||||
print('这是请求钩子 before_first_request 注册的函数')
|
||||
|
||||
@app.before_request
|
||||
def before_request():
|
||||
print('这是请求钩子 before_request 注册的函数')
|
||||
|
||||
@app.route('/index')
|
||||
def index():
|
||||
print('hello flask')
|
||||
@after_this_request
|
||||
def after_this_request_func(response):
|
||||
print('这是请求钩子 after_this_request_func 注册的函数')
|
||||
return response
|
||||
return 'hello flask'
|
||||
|
||||
@app.after_request
|
||||
def after_request(response):
|
||||
print('这是请求钩子 after_request 注册的函数')
|
||||
return response
|
||||
|
||||
@app.teardown_request
|
||||
def teardown_request(error):
|
||||
print('这是请求钩子 teardown_request 注册的函数')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
26
2026-04-14/2026-04-14_hw_2.py
Normal file
26
2026-04-14/2026-04-14_hw_2.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from flask import Flask, url_for, request, redirect, session
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = 'Your_secret_key$^52@!'
|
||||
|
||||
@app.route('/index')
|
||||
def index():
|
||||
if 'username' in session:
|
||||
return f'你好,{session.get("username")}'
|
||||
return redirect(url_for("login"))
|
||||
|
||||
@app.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
if request.method == 'POST':
|
||||
session['username'] = request.form['username']
|
||||
return redirect(url_for('index'))
|
||||
# 当发送GET请求时,页面显示输入框和"登录"按钮
|
||||
return '''
|
||||
<form method="post">
|
||||
<p><input type=text name=username>
|
||||
<p><input type=submit value=登录>
|
||||
</form>
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
BIN
2026-04-14/2026-04-14_hw_3.docx
Normal file
BIN
2026-04-14/2026-04-14_hw_3.docx
Normal file
Binary file not shown.
BIN
2026-04-14/24计应1_杨近澜_1113_2026-04-14作业.docx
Normal file
BIN
2026-04-14/24计应1_杨近澜_1113_2026-04-14作业.docx
Normal file
Binary file not shown.
13
2026-04-21/2026-04-21_hw_1.py
Normal file
13
2026-04-21/2026-04-21_hw_1.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from flask import *
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/")
|
||||
@app.route("/index/")
|
||||
def index():
|
||||
info = [1, 2, 3, 4, 5]
|
||||
return render_template("2026-04-21_hw_1.html", info=info)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
19
2026-04-21/2026-04-21_hw_2.py
Normal file
19
2026-04-21/2026-04-21_hw_2.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from flask import *
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/")
|
||||
@app.route("/filters/")
|
||||
def use_of_filters():
|
||||
num = -2.3
|
||||
li = [2, 1, 5, 6, 7, 4, 4]
|
||||
string = 'flask'
|
||||
return render_template('2026-04-21_hw_2.html', num=num, li=li, string=string)
|
||||
|
||||
@app.template_filter() # 注册自定义过滤器
|
||||
def reverse(data): # 自定义过滤器
|
||||
return data[::-1]
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
14
2026-04-21/2026-04-21_hw_3.py
Normal file
14
2026-04-21/2026-04-21_hw_3.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from flask import *
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
count_p = 0
|
||||
|
||||
@app.route("/<int:score>/")
|
||||
@app.route('/query-score/<int:score>/')
|
||||
def query_score(score):
|
||||
return render_template('2026-04-21_hw_3.html',score=score)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
BIN
2026-04-21/24计应1_杨近澜_1113_2026-04-21作业.docx
Normal file
BIN
2026-04-21/24计应1_杨近澜_1113_2026-04-21作业.docx
Normal file
Binary file not shown.
11
2026-04-21/templates/2026-04-21_hw_1.html
Normal file
11
2026-04-21/templates/2026-04-21_hw_1.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Homework</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello Flask!</h1>
|
||||
<h2>info: {{info[3]}}</h2>
|
||||
</body>
|
||||
</html>
|
||||
23
2026-04-21/templates/2026-04-21_hw_2.html
Normal file
23
2026-04-21/templates/2026-04-21_hw_2.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Homework</title>
|
||||
</head>
|
||||
<body>
|
||||
{#返回变量num的绝对值#}
|
||||
<h4>绝对值:{{ num|abs }}</h4>
|
||||
{#将变量num转换为整型#}
|
||||
<h4>转换为整型:{{ num|int }}</h4>
|
||||
{#返回变量li中随机的一个元素#}
|
||||
<h4>获取随机元素:{{ li|random }}</h4>
|
||||
{#返回变量li的长度#}
|
||||
<h4>获取列表长度:{{ li|length }}</h4>
|
||||
<h4>列表排序:{{ li|sort }}</h4>
|
||||
<h4>首字母大写: {{ string|capitalize }}</h4>
|
||||
<h4>字母全大写: {{ string|upper }}</h4>
|
||||
<h4>字符拼接: {{ string|join("-") }}</h4>
|
||||
<h4>列表: {{ li }}</h4>
|
||||
<h4>列表排序:{{ li|reverse }}</h4>
|
||||
</body>
|
||||
</html>
|
||||
59
2026-04-21/templates/2026-04-21_hw_3.html
Normal file
59
2026-04-21/templates/2026-04-21_hw_3.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
.score{
|
||||
width: 12em;
|
||||
height: 4em;
|
||||
line-height: 4em;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
border: 2px solid black;
|
||||
border-radius: 0.5em;
|
||||
}
|
||||
|
||||
.excellent{
|
||||
background-color: purple;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.lhz{
|
||||
background-color: greenyellow;
|
||||
}
|
||||
|
||||
.middle{
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
._60{
|
||||
background-color: orange;
|
||||
}
|
||||
|
||||
._59{
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.worse {
|
||||
background-color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% if score >= 90 %}
|
||||
<div class="score excellent">优秀</div>
|
||||
{% elif 80 <= score < 90 %}
|
||||
<div class="score lhz">良好</div>
|
||||
{% elif 70 <= score < 80 %}
|
||||
<div class="score middle">中等</div>
|
||||
{% elif 60 <= score < 70 %}
|
||||
<div class="score _60">及格</div>
|
||||
{% elif 59 <= score < 60 %}
|
||||
<div class="score _59">恭喜你,差点就及格了</div>
|
||||
{% else %}
|
||||
<div class="score worse">不及格</div>
|
||||
{% endif %}
|
||||
</body>
|
||||
|
||||
</html>
|
||||
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>
|
||||
29
2026-05-12/2026-05-12_hw_1.py
Normal file
29
2026-05-12/2026-05-12_hw_1.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from flask import Flask, render_template
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, PasswordField, SubmitField
|
||||
from wtforms.validators import DataRequired, Length, EqualTo
|
||||
|
||||
app = Flask(__name__)
|
||||
app.secret_key = '34sdfji9453#$@'
|
||||
|
||||
|
||||
class RegisterForm(FlaskForm):
|
||||
username = StringField(label='用户名:',
|
||||
validators=[DataRequired(message='用户名不能为空'),
|
||||
Length(3, 15, message='长度应该为3~15个字符')])
|
||||
password = PasswordField('密码:',
|
||||
validators=[DataRequired(message='密码不能为空')])
|
||||
password2 = PasswordField('确认密码:',
|
||||
validators=[DataRequired(message='密码不能为空'),
|
||||
EqualTo('password', message='两次密码不一致')])
|
||||
submit = SubmitField('注册')
|
||||
|
||||
|
||||
@app.route('/register', methods=['GET', 'POST'])
|
||||
def register():
|
||||
form = RegisterForm()
|
||||
return render_template('register_wtf.html', form=form)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
BIN
2026-05-12/24计应1_杨近澜_1113_2026-05-12作业.docx
Normal file
BIN
2026-05-12/24计应1_杨近澜_1113_2026-05-12作业.docx
Normal file
Binary file not shown.
21
2026-05-12/templates/register_wtf.html
Normal file
21
2026-05-12/templates/register_wtf.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<h1>注册页面</h1>
|
||||
<form method="post">
|
||||
{{ form.csrf_token }}
|
||||
{#获取username对应的标签名称#}
|
||||
<span>{{ form.username.label }}</span><br>
|
||||
{#调用表单字段#}
|
||||
{{ form.username }}<br>
|
||||
<span>{{ form.password.label }}</span><br>
|
||||
{{ form.password }}<br>
|
||||
<span>{{ form.password2.label }}</span><br>
|
||||
{{ form.password2 }}<br>
|
||||
<p>{{ form.submit }}</p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
25
2026-05-19/2026-05-19_hw_1.py
Normal file
25
2026-05-19/2026-05-19_hw_1.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from flask.views import MethodView
|
||||
from flask import Flask, render_template, request
|
||||
|
||||
class LoginView(MethodView):
|
||||
def get(self):
|
||||
# 处理 GET 请求:展示登录页面
|
||||
return render_template('login.html')
|
||||
|
||||
def post(self):
|
||||
# 处理 POST 请求:获取表单数据并校验
|
||||
username = request.form.get('username') # 获取输入的用户名
|
||||
password = request.form.get('password') # 获取输入的密码
|
||||
|
||||
# 判断用户名是否为 flask、密码是否为 123
|
||||
if username == 'flask' and password == '123':
|
||||
return f'用户:{username}登录成功。'
|
||||
else:
|
||||
return '用户名或密码错误,请重新登录。'
|
||||
|
||||
app = Flask(__name__)
|
||||
# 将类视图与 URL 进行映射
|
||||
app.add_url_rule('/login', view_func=LoginView.as_view('login'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
BIN
2026-05-19/24计应1_杨近澜_1113_2026-05-19作业.docx
Normal file
BIN
2026-05-19/24计应1_杨近澜_1113_2026-05-19作业.docx
Normal file
Binary file not shown.
16
2026-05-19/templates/login.html
Normal file
16
2026-05-19/templates/login.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>hw</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="" method="post">
|
||||
<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>
|
||||
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第10章 错误和异常.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第10章 错误和异常.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第1章 开启Python学习之旅.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第1章 开启Python学习之旅.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第2章 数字类型与字符串.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第2章 数字类型与字符串.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第3章 流程控制.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第3章 流程控制.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第4章 列表与元组.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第4章 列表与元组.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第5章 字典和集合.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第5章 字典和集合.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第6章 函数.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第6章 函数.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第7章 类与面向对象.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第7章 类与面向对象.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第8章 模块.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第8章 模块.pptx
Normal file
Binary file not shown.
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第9章 文件与文件路径操作.pptx
Normal file
BIN
Python程序开发案例教程_黑马(第2版)-教学PPT/Python基础-第9章 文件与文件路径操作.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第10章 智能租房——用户中心.pptx
Normal file
BIN
《Web编程技术》PPT/第10章 智能租房——用户中心.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第1章 认识Flask.pptx
Normal file
BIN
《Web编程技术》PPT/第1章 认识Flask.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第2章 路由.pptx
Normal file
BIN
《Web编程技术》PPT/第2章 路由.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第3章 模板.pptx
Normal file
BIN
《Web编程技术》PPT/第3章 模板.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第4章 表单与类视图.pptx
Normal file
BIN
《Web编程技术》PPT/第4章 表单与类视图.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第5章 数据库操作.pptx
Normal file
BIN
《Web编程技术》PPT/第5章 数据库操作.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第6章 智能租房——前期准备.pptx
Normal file
BIN
《Web编程技术》PPT/第6章 智能租房——前期准备.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第7章 智能租房——首页.pptx
Normal file
BIN
《Web编程技术》PPT/第7章 智能租房——首页.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第8章 智能租房——列表页.pptx
Normal file
BIN
《Web编程技术》PPT/第8章 智能租房——列表页.pptx
Normal file
Binary file not shown.
BIN
《Web编程技术》PPT/第9章 智能租房——详情页.pptx
Normal file
BIN
《Web编程技术》PPT/第9章 智能租房——详情页.pptx
Normal file
Binary file not shown.
Reference in New Issue
Block a user