-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_webpy.py
More file actions
55 lines (36 loc) · 1.23 KB
/
test_webpy.py
File metadata and controls
55 lines (36 loc) · 1.23 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
'''
test_webpy.py
@summary: Comparing (RAM usage) of different webframeworks
@since: 4 Mar 2016
@author: Andreas
@home github.com/drandreaskrueger/pythonMicroframeworks
@license: MIT but please donate:
@bitcoin: 14EyWS5z8Y5kgwq52D3qeZVor1rUsdNYJy
@thanks: to Kevin Veroneau. I based parts of this on his code snippets.
http://www.pythondiary.com/blog/Feb.14,2012/too-many-micro-webframeworks.html
'''
import web # pip install web.py
# HOST, PORT= '0.0.0.0', 8080
HOST, PORT= '127.0.0.1', 8080
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
if not name:
name = 'Earth'
return 'Hello, ' + name + '!'
def run_simplest():
app.run()
def run_server(host=HOST, port=PORT):
print "web.py:",
web.httpserver.runsimple(app.wsgifunc(), (host, port))
def url(host=HOST, port=PORT):
return "http://%s:%s/World" % (host, port)
def version():
return ("web.py", web.__version__)
if __name__ == '__main__':
# run_simplest()
from sys import argv as a; port=int(a[1]) if len(a)>1 else PORT # get port from commandline argument
run_server(port=port)