forked from arskom/spyne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
from datetime import datetime | ||
from rpclib.model.primitive import Integer,Unicode | ||
from rpclib.decorator import srpc | ||
from rpclib.service import ServiceBase | ||
|
||
class NameOfMonthService(ServiceBase): | ||
@srpc(Integer(ge=1,le=12), _returns=Unicode) | ||
def get_name_of_month(month): | ||
return datetime(2000,month,1).strftime("%B") | ||
|
||
|
||
from rpclib.application import Application | ||
from rpclib.protocol.http import HttpRpc | ||
|
||
rest = Application([NameOfMonthService], | ||
tns='rpclib.examples.multiprot', | ||
in_protocol=HttpRpc(validator='soft'), | ||
out_protocol=HttpRpc() | ||
) | ||
|
||
import logging | ||
|
||
from rpclib.server.wsgi import WsgiApplication | ||
from wsgiref.simple_server import make_server | ||
|
||
host = '127.0.0.1' | ||
port = 9912 | ||
|
||
server = make_server(host, port, WsgiApplication(rest)) | ||
|
||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
logging.info("listening to http://%s:%d" % (host,port)) | ||
|
||
server.serve_forever() |