コード例 #1
0
ファイル: testhttp.py プロジェクト: softsoft/concurrence
    def setUp(self):
        application = WSGISimpleRouter()
        for i in range(10):
            application.map('/hello/%d' % i,
                            WSGISimpleMessage("Hello World %d" % i))

        class WSGISleeper(WSGISimpleMessage):
            def __call__(self, environ, start_response):
                sleep_seconds = int(environ['QUERY_STRING'])
                Tasklet.sleep(sleep_seconds)
                self.response = 'slept %d' % sleep_seconds
                return WSGISimpleMessage.__call__(self, environ,
                                                  start_response)

        class WSGIPOSTSaver(WSGISimpleMessage):
            def __call__(self, environ, start_response):
                self.environ = environ
                f = environ['wsgi.input']
                self.body = f.read(int(environ['HTTP_CONTENT_LENGTH']))
                return WSGISimpleMessage.__call__(self, environ,
                                                  start_response)

        self.saver = WSGIPOSTSaver('ok')
        application.map('/sleep', WSGISleeper('zzz...'))
        application.map('/post', self.saver)

        self.server = WSGIServer(application)
        self.socket_server = self.server.serve(('0.0.0.0', SERVER_PORT))
コード例 #2
0
ファイル: testhttp.py プロジェクト: bradjasper/concurrence
    def setUp(self):
        application = WSGISimpleRouter()
        for i in range(10):
            application.map('/hello/%d' % i, WSGISimpleMessage("Hello World %d" % i))

        class WSGISleeper(WSGISimpleMessage):
            def __call__(self, environ, start_response):
                sleep_seconds = int(environ['QUERY_STRING'])
                Tasklet.sleep(sleep_seconds)
                self.response = 'slept %d' % sleep_seconds
                return WSGISimpleMessage.__call__(self, environ, start_response)

        class WSGIPOSTSaver(WSGISimpleMessage):
            def __call__(self, environ, start_response):
                self.environ = environ
                f = environ['wsgi.input']
                self.body = f.read(int(environ['HTTP_CONTENT_LENGTH']))
                return WSGISimpleMessage.__call__(self, environ, start_response)                
            
        self.saver = WSGIPOSTSaver('ok')
        application.map('/sleep', WSGISleeper('zzz...'))
        application.map('/post', self.saver)

        self.server = WSGIServer(application)
        self.socket_server = self.server.serve(('0.0.0.0', SERVER_PORT))
コード例 #3
0
ファイル: post.py プロジェクト: winner0911/concurrence
def main():
    application = WSGISimpleRouter()

    from wsgiref.validate import validator

    application.map('/form', validator(show_form))
    application.map('/upload', upload_form)
    application.map('/process', process_form)

    server = WSGIServer(application)
    server.serve(('localhost', 8080))