예제 #1
0
 def setUpClass(cls):
     cls._httpd = wsgi_boost.WsgiBoostHttp(threads=1)
     cls._httpd.add_static_route('^/static', cwd)
     cls._httpd.add_static_route('^/invalid_dir', '/foo/bar/baz/')
     cls._server_thread = threading.Thread(target=cls._httpd.start)
     cls._server_thread.daemon = True
     cls._server_thread.start()
     time.sleep(0.5)
예제 #2
0
 def setUpClass(cls):
     cls._httpd = wsgi_boost.WsgiBoostHttp(threads=1)
     app = App()
     cls._httpd.set_app(validator(app))
     cls._server_thread = threading.Thread(target=cls._httpd.start)
     cls._server_thread.daemon = True
     cls._server_thread.start()
     time.sleep(0.5)
예제 #3
0
 def setUpClass(cls):
     cls._httpd = wsgi_boost.WsgiBoostHttp(threads=1)
     app = App()
     cls._httpd.set_app(app)
     cls._server_thread = threading.Thread(target=cls._httpd.start)
     cls._server_thread.daemon = True
     cls._server_thread.start()
     time.sleep(0.5)
     with open('german.txt', mode='r') as fo:
         cls._data = fo.read()
예제 #4
0
 def test_validate_wsgi_server_compliance(self):
     httpd = wsgi_boost.WsgiBoostHttp(num_threads=1)
     app = App()
     httpd.set_app(validator(app))
     server_thread = threading.Thread(target=httpd.start)
     server_thread.daemon = True
     server_thread.start()
     time.sleep(0.5)
     resp = requests.get('http://127.0.0.1:8000/')
     self.assertEqual(resp.status_code, 200)
     self.assertTrue('App OK' in resp.text)
     httpd.stop()
     server_thread.join()
예제 #5
0
#!/usr/bin/env python
"""
This example demonstrates serving a very simple WSGI application
"""

import os
import sys

cwd = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.dirname(cwd))

import wsgi_boost


def hello_app(environ, start_response):
    """Very simple WSGI application"""
    content = b'Hello World!'
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(content)))]
    start_response('200 OK', response_headers)
    return [content]


if __name__ == '__main__':
    # Create a server on the default port 8000 with 4 threads
    httpd = wsgi_boost.WsgiBoostHttp(threads=4)
    httpd.set_app(hello_app)
    httpd.start()
예제 #6
0
#!/usr/bin/env python
"""
WsgiBoostServer benchmark
"""

import wsgi_boost


def hello_app(environ, start_response):
    content = b'Hello World!'
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(content)))]
    start_response('200 OK', response_headers)
    return [content]


if __name__ == '__main__':
    httpd = wsgi_boost.WsgiBoostHttp(num_threads=10)
    httpd.set_app(hello_app)
    httpd.start()