-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.py
54 lines (35 loc) · 1.22 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from flask import Flask
from flask import request
app = Flask(__name__)
# app = Flask(
# __name__,
# template_folder=".",
# static_folder=".",
# static_url_path=""
# )
@app.route('/', methods=['GET', 'POST'])
def home():
html_txt='Hell0'
#with open("index_shadow3.html","r") as txt:
with open("index.html","r") as txt:
html_txt = ""
html = list(txt.readlines())
html_txt = "".join(html )
return html_txt
@app.route('/signin', methods=['GET'])
def signin_form():
return '''<form action="/signin" method="post">
<p><input name="username"></p>
<p><input name="password" type="password"></p>
<p><button type="submit">Sign In</button></p>
</form>'''
@app.route('/signin', methods=['POST'])
def signin():
# 需要从request对象读取表单内容:
if request.form['username']=='1' and request.form['password']=='1':
return '<h3>Hello, admin!</h3>'
return '<h3>Bad username or password.</h3>'
if __name__ == '__main__':
app.run(debug=False,host='192.168.31.239',port=8000,ssl_context="adhoc")
#debug=False,host='192.168.1.111',port=5000 192.168.9.106
#ipconfig 192.168.1.111 127.0.9.1