-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello.py
41 lines (33 loc) · 922 Bytes
/
hello.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
import web
import MySQLdb
import MySQLdb.cursors
urls = (
'/index', 'index',
'/blog/\\d+', 'blog',
'/article', 'article',
'/(.*)', 'hello',
)
app = web.application(urls, globals())
class index:
def GET(self):
return web.input()
class blog:
def GET(self):
return web.ctx.env
def POST(self):
return 'blog post method'
class hello:
def GET(self, name):
return open(r'http://www.baidu.com').read()
class article:
def GET(self):
conn = MySQLdb.connect(host='192.168.100.36',user='root',passwd='root',db='oa_db',port=3306,cursorclass=MySQLdb.cursors.DictCursor,charset='utf8')
cur = conn.cursor()
cur.execute('select * from user')
r = cur.fetchall()
cur.close()
conn.close()
print r
return r
if __name__ == "__main__":
app.run()