Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
211cc4e3
Commit
211cc4e3
authored
Sep 09, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor updates in examples; make httpserver and wsgiserver serve on the same port
parent
a839ee8d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
examples/concurrent_download.py
examples/concurrent_download.py
+1
-1
examples/httpserver.py
examples/httpserver.py
+5
-3
examples/wsgiserver.py
examples/wsgiserver.py
+3
-4
No files found.
examples/concurrent_download.py
View file @
211cc4e3
...
...
@@ -10,7 +10,7 @@ monkey.patch_socket() # patches regular socket to yield to other greenlets
import
urllib2
from
gevent.pool
import
Pool
# Pool accepts one optional argument -
a
maximum number of concurrent
# Pool accepts one optional argument - maximum number of concurrent
# coroutines that can be active at any given moment.
# Try passing 1 or 2 here to see the effect.
pool
=
Pool
()
...
...
examples/httpserver.py
100644 → 100755
View file @
211cc4e3
"""HTTP server listening on port 8800.
#!/usr/bin/python
"""HTTP server example.
Uses libevent API directly and thus may be dangerous.
WSGI interface is probably a safer choice, see examples/wsgiserver.py.
...
...
@@ -6,6 +7,7 @@ WSGI interface is probably a safer choice, see examples/wsgiserver.py.
from
gevent
import
http
def
callback
(
r
):
print
r
if
r
.
uri
==
'/'
:
r
.
add_output_header
(
'Content-Type'
,
'text/html'
)
r
.
send_reply
(
200
,
"OK"
,
'<b>hello world</b>'
)
...
...
@@ -13,5 +15,5 @@ def callback(r):
r
.
add_output_header
(
'Content-Type'
,
'text/html'
)
r
.
send_reply
(
404
,
"Not Found"
,
"<h1>Not Found</h1>"
)
print
__doc__
http
.
HTTPServer
(
callback
).
serve_forever
((
'0.0.0.0'
,
8
800
))
print
'Serving on 8088...'
http
.
HTTPServer
(
callback
).
serve_forever
((
'0.0.0.0'
,
8
088
))
examples/wsgiserver.py
View file @
211cc4e3
#/usr/bin/python
"""Simple wsgi app. Serving on 8088.
"""
#!/usr/bin/python
"""WSGI server example"""
from
gevent
import
wsgi2
...
...
@@ -12,6 +11,6 @@ def hello_world(env, start_response):
start_response
(
'404 Not Found'
,
[(
'Content-Type'
,
'text/plain'
)])
return
[
'Not Found
\
r
\
n
'
]
print
__doc__
print
'Serving on 8088...'
wsgi2
.
WSGIServer
((
''
,
8088
),
hello_world
).
serve_forever
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment