Zzzztt commited on
Commit
dae5ae4
·
verified ·
1 Parent(s): 763ad41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -15,3 +15,31 @@ def chat():
15
 
16
  if __name__ == '__main__':
17
  app.run(host='0.0.0.0', port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  if __name__ == '__main__':
17
  app.run(host='0.0.0.0', port=7860)
18
+ from flask import Flask, request, render_template_string
19
+
20
+ app = Flask(__name__)
21
+
22
+ # 预设用户名和密码
23
+ USERS = {"admin": "123456"}
24
+
25
+ @app.route('/login', methods=['GET', 'POST'])
26
+ def login():
27
+ if request.method == 'POST':
28
+ username = request.form.get('username')
29
+ password = request.form.get('password')
30
+ if username in USERS and USERS[username] == password:
31
+ return "登录成功!"
32
+ else:
33
+ return "登录失败,用户名或密码错误!"
34
+
35
+ # 简单的 HTML 登录表单
36
+ return render_template_string('''
37
+ <form method="POST">
38
+ 用户名: <input type="text" name="username"><br>
39
+ 密码: <input type="password" name="password"><br>
40
+ <input type="submit" value="登录">
41
+ </form>
42
+ ''')
43
+
44
+ if __name__ == '__main__':
45
+ app.run(host='0.0.0.0', port=7860)