diff --git a/2026-05-19/2026-05-19_hw_1.py b/2026-05-19/2026-05-19_hw_1.py new file mode 100644 index 0000000..e464ec9 --- /dev/null +++ b/2026-05-19/2026-05-19_hw_1.py @@ -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() \ No newline at end of file diff --git a/2026-05-19/24计应1_杨近澜_1113_2026-05-19作业.docx b/2026-05-19/24计应1_杨近澜_1113_2026-05-19作业.docx new file mode 100644 index 0000000..af1b9d4 Binary files /dev/null and b/2026-05-19/24计应1_杨近澜_1113_2026-05-19作业.docx differ diff --git a/2026-05-19/templates/login.html b/2026-05-19/templates/login.html new file mode 100644 index 0000000..b073bbc --- /dev/null +++ b/2026-05-19/templates/login.html @@ -0,0 +1,16 @@ + + +
+ +