diff --git a/2026-04-21/2026-04-21_hw_1.py b/2026-04-21/2026-04-21_hw_1.py new file mode 100644 index 0000000..5c16534 --- /dev/null +++ b/2026-04-21/2026-04-21_hw_1.py @@ -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() \ No newline at end of file diff --git a/2026-04-21/2026-04-21_hw_2.py b/2026-04-21/2026-04-21_hw_2.py new file mode 100644 index 0000000..ef5410c --- /dev/null +++ b/2026-04-21/2026-04-21_hw_2.py @@ -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() \ No newline at end of file diff --git a/2026-04-21/2026-04-21_hw_3.py b/2026-04-21/2026-04-21_hw_3.py new file mode 100644 index 0000000..16fd845 --- /dev/null +++ b/2026-04-21/2026-04-21_hw_3.py @@ -0,0 +1,14 @@ +from flask import * + + +app = Flask(__name__) + +count_p = 0 + +@app.route("//") +@app.route('/query-score//') +def query_score(score): + return render_template('2026-04-21_hw_3.html',score=score) + +if __name__ == "__main__": + app.run() \ No newline at end of file diff --git a/2026-04-21/24计应1_杨近澜_1113_2026-04-21作业.docx b/2026-04-21/24计应1_杨近澜_1113_2026-04-21作业.docx new file mode 100644 index 0000000..4eb5714 Binary files /dev/null and b/2026-04-21/24计应1_杨近澜_1113_2026-04-21作业.docx differ diff --git a/2026-04-21/templates/2026-04-21_hw_1.html b/2026-04-21/templates/2026-04-21_hw_1.html new file mode 100644 index 0000000..9d9ac31 --- /dev/null +++ b/2026-04-21/templates/2026-04-21_hw_1.html @@ -0,0 +1,11 @@ + + + + + Homework + + +

Hello Flask!

+

info: {{info[3]}}

+ + \ No newline at end of file diff --git a/2026-04-21/templates/2026-04-21_hw_2.html b/2026-04-21/templates/2026-04-21_hw_2.html new file mode 100644 index 0000000..71efdd4 --- /dev/null +++ b/2026-04-21/templates/2026-04-21_hw_2.html @@ -0,0 +1,23 @@ + + + + + Homework + + + {#返回变量num的绝对值#} +

绝对值:{{ num|abs }}

+ {#将变量num转换为整型#} +

转换为整型:{{ num|int }}

+ {#返回变量li中随机的一个元素#} +

获取随机元素:{{ li|random }}

+ {#返回变量li的长度#} +

获取列表长度:{{ li|length }}

+

列表排序:{{ li|sort }}

+

首字母大写: {{ string|capitalize }}

+

字母全大写: {{ string|upper }}

+

字符拼接: {{ string|join("-") }}

+

列表: {{ li }}

+

列表排序:{{ li|reverse }}

+ + \ No newline at end of file diff --git a/2026-04-21/templates/2026-04-21_hw_3.html b/2026-04-21/templates/2026-04-21_hw_3.html new file mode 100644 index 0000000..d1a379e --- /dev/null +++ b/2026-04-21/templates/2026-04-21_hw_3.html @@ -0,0 +1,59 @@ + + + + + + + + + {% if score >= 90 %} +
优秀
+ {% elif 80 <= score < 90 %} +
良好
+ {% elif 70 <= score < 80 %} +
中等
+ {% elif 60 <= score < 70 %} +
及格
+ {% elif 59 <= score < 60 %} +
恭喜你,差点就及格了
+ {% else %} +
不及格
+ {% endif %} + + + \ No newline at end of file