-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_web.py
More file actions
65 lines (50 loc) · 1.55 KB
/
http_web.py
File metadata and controls
65 lines (50 loc) · 1.55 KB
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
55
56
57
58
59
60
61
62
63
64
65
from flask import Flask, session,render_template,send_file
from mysql_getdata import BD, get_date
app = Flask(__name__)
@app.route('/')
def hello():
bd = BD("visitors")
if session == {}:
session['id'] = bd.get_next_id()
bd.set_visit(session['id'], get_date())
count = bd.get_all(session['id'])
print(count)
return "Your visits is {}.\n".format(count)
@app.route('/D/')
def hello_d():
bd = BD("visitors")
if session == {}:
session['id'] = bd.get_next_id()
bd.set_visit(session['id'], get_date())
count = bd.get_day(session['id'], get_date())
return "Your visits is {}.\n".format(count)
@app.route('/M/')
def hello_m():
bd = BD("visitors")
if session == {}:
session['id'] = bd.get_next_id()
bd.set_visit(session['id'], get_date())
count = bd.get_month(session['id'], get_date())
return "Your visits is {}.\n".format(count)
@app.route('/Y/')
def hello_y():
bd = BD("visitors")
if session == {}:
session['id'] = bd.get_next_id()
bd.set_visit(session['id'], get_date())
count = bd.get_year(session['id'], get_date())
return "Your visits is {}.\n".format(count)
@app.route('/img/')
def hello_I():
bd = BD("visitors")
if session == {}:
session['id'] = bd.get_next_id()
bd.set_visit(session['id'], get_date())
return send_file('p.png')
def main():
app.debug = False
app.secret_key =\
b'\xcbt\x0f\xbfAQd\x16\x91\xa4\x1f\x8b\xa2j\xc8k\x19^\xf19\xf4Bq\xe1'
app.run(host='0.0.0.0')
if __name__ == '__main__':
main()