Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shrapnel
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
shrapnel
Commits
07c3820d
Commit
07c3820d
authored
Jun 15, 2013
by
Sam Rushing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demo the json rpc handler
parent
b9447f2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
coro/http/demo/jsonrpc.py
coro/http/demo/jsonrpc.py
+26
-0
No files found.
coro/http/demo/jsonrpc.py
0 → 100644
View file @
07c3820d
# -*- Mode: Python -*-
import
coro
import
coro.http
import
coro.backdoor
import
coro.http.json_rpc
import
operator
W
=
coro
.
write_stderr
class
server_root
:
def
handle_json_rpc
(
self
,
method
,
params
):
W
(
'method=%r params=%r
\
n
'
%
(
method
,
params
))
if
method
==
'sum'
:
return
sum
(
params
)
else
:
return
None
server
=
coro
.
http
.
server
()
server
.
push_handler
(
coro
.
http
.
json_rpc
.
json_rpc_handler
(
server_root
()))
server
.
push_handler
(
coro
.
http
.
handlers
.
coro_status_handler
())
server
.
push_handler
(
coro
.
http
.
handlers
.
favicon_handler
())
coro
.
spawn
(
server
.
start
,
(
'0.0.0.0'
,
9001
))
coro
.
spawn
(
coro
.
backdoor
.
serve
,
unix_path
=
'/tmp/httpd.bd'
)
coro
.
event_loop
(
30.0
)
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