Compare commits
9 Commits
8fc93fcc0e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 546f231698 | |||
| 8dd1fae2e1 | |||
| 6b51126213 | |||
| dd21ddbaef | |||
| b0db5b3239 | |||
| af13f500e1 | |||
| 2ae54f2f06 | |||
| 5dcc0fcada | |||
| 243711134c |
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="")
|
||||||
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
《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