def runserver(): """Lance un serveur wsgi de test, puis lui attribue l'application a lancer avec eventuellement le chainage de middleware """ from pyson.middleware.error import HandleError from pyson.middleware.log import Log from pyson.middleware.session import Session #se wrapp automatiquement avec cookie from pyson.middleware.force_auth import Force_auth from pyson.middleware.http_basic import Http_basic from pyson.middleware.formdata import Formdata from pyson.middleware.restriction import Middle as Restriction if os.environ.get("REQUEST_METHOD", ""): from wsgiref.handlers import BaseCGIHandler BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ).run(urls.urls) print "------------- Attention ---------------" else: import wsgiref from wsgiref.simple_server import WSGIServer, WSGIRequestHandler httpd = WSGIServer(('', int(context.conf["port"])), WSGIRequestHandler) wrapper = Session(Formdata((Restriction(urls.urls)))) httpd.set_app(wrapper) print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname() httpd.serve_forever()
def runCGI(self, input, output, errors, env, argv=()): from wsgiref.handlers import BaseCGIHandler BaseCGIHandler(input, output, errors, env, multithread=False, multiprocess=True).run(self.subject)
def run(): import urls if os.environ.get('REQUEST_METHOD', ''): from wsgiref.handlers import BaseCGIHandler BaseCGIHandler( sys.stdin, sys.stdout, sys.stderr, os.environ).run(urls.urls) else: from wsgiref.simple_server import WSGIServer, WSGIRequestHandler httpd = WSGIServer(('', 8080), WSGIRequestHandler) httpd.set_app(urls.urls) print "Server HTTP on %s port %s..." % httpd.socket.getsockname() httpd.serve_forever()
def run(): import urls if os.environ.get("REQUEST_METHOD", ""): from wsgiref.handlers import BaseCGIHandler BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ) \ .run(urls.load('urls.map')) else: os.environ = {} from wsgiref.simple_server import WSGIServer, WSGIRequestHandler httpd = WSGIServer(('', 8080), WSGIRequestHandler) httpd.set_app(urls.load('urls.map')) print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname() httpd.serve_forever()
def run(): import urls if os.environ.get("REQUEST_METHOD", ""): from wsgiref.handlers import BaseCGIHandler f = file("log", "a") BaseCGIHandler(sys.stdin, sys.stdout, f, os.environ).run(urls.urls) f.close() else: from wsgiref.simple_server import WSGIServer, WSGIRequestHandler httpd = WSGIServer(('', 8080), WSGIRequestHandler) httpd.set_app(urls.urls) print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname() httpd.serve_forever()
def run(): import urls if os.environ.get('REQUEST_METHOD', ''): from wsgiref.handlers import BaseCGIHandler BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ).run(urls.urls) else: from wsgiref.simple_server import WSGIServer, WSGIRequestHandler httpd = WSGIServer(('', 8080), WSGIRequestHandler) httpd.set_app(urls.urls) host, port = httpd.socket.getsockname()[:2] print 'Serving HTTP on {0} port {1}...'.format(host, port) httpd.serve_forever()
def run(): """ run server """ from users import urls if os.environ.get("REQUEST_METHOD", ""): from wsgiref.handlers import BaseCGIHandler BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ).run(urls.urls) else: from wsgiref.simple_server import WSGIServer, WSGIRequestHandler from beaker.middleware import SessionMiddleware session_opts = { 'session.type': 'file', 'session.cookie_expires': True, 'session.data_dir': 'var', } app = SessionMiddleware(urls.urls, session_opts) httpd = WSGIServer(('', 8080), WSGIRequestHandler) httpd.set_app(app) print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname() httpd.serve_forever()
def testCGIEnviron(self): h = BaseCGIHandler(None, None, None, {}) h.setup_environ() for key in 'wsgi.url_scheme', 'wsgi.input', 'wsgi.errors': self.assertIn(key, h.environ)