我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用paste.httpserver.serve()。
def handle(self, url, method): """ Execute the handler bound to the specified url and method and return its output. If catchall is true, exceptions are catched and returned as HTTPError(500) objects. """ if not self.serve: return HTTPError(503, "Server stopped") try: handler, args = self.match_url(url, method) return handler(**args) except HTTPResponse as e: return e except Exception as e: if isinstance(e, (KeyboardInterrupt, SystemExit, MemoryError))\ or not self.catchall: raise return HTTPError(500, 'Unhandled exception', e, format_exc(10))
def main(): parser = argparse.ArgumentParser() parser.add_argument('--listen', help='host:port to listen on', default='127.0.0.1:8083') args = parser.parse_args() host, port = args.listen.split(':') app = webapp2.WSGIApplication([ ('/kataster_info_location', KatasterInfoLocation), ('/kataster_info_company', KatasterInfoCompany), ('/kataster_info_person', KatasterInfoPerson), ('/kataster_info_politician', KatasterInfoPolitician), ('/list_politicians', ListPoliticians), ('/info_politician', InfoPolitician), ('/asset_declarations', AssetDeclarations), ], debug=False) httpserver.serve( app, host=host, port=port)
def main(): app = webapp2.WSGIApplication( [ ('/obstaravanie', ServeObstaravanie), ('/obstaravanieFirma', ServeCompany), ('/notifications', ServeNotifications), ('/updateNotifications', UpdateNotifications), ], debug=False) parser = argparse.ArgumentParser() parser.add_argument('--listen', help='host:port to listen on', default='127.0.0.1:8082') args = parser.parse_args() host, port = args.listen.split(':') httpserver.serve( app, host=host, port=port)
def main(): app = webapp2.WSGIApplication([ ('/connection', Connection), ('/shortest', ShortestPath), ('/neighbourhood', Neighbourhood) ], debug=False) parser = argparse.ArgumentParser() parser.add_argument('--listen', help='host:port to listen on', default='127.0.0.1:8081') args = parser.parse_args() host, port = args.listen.split(':') httpserver.serve( app, host=host, port=port)
def __init__(self, catchall=True, autojson=True, config=None): """ Create a new bottle instance. You usually don't do that. Use `bottle.app.push()` instead. """ self.routes = [] # List of installed routes including metadata. self.callbacks = {} # Cache for wrapped callbacks. self.router = Router() # Maps to self.routes indices. self.mounts = {} self.error_handler = {} self.catchall = catchall self.config = config or {} self.serve = True self.castfilter = [] if autojson and json_dumps: self.add_filter(dict, dict2json) self.hooks = {'before_request': [], 'after_request': []}
def handle(self, environ): """ Execute the handler bound to the specified url and method and return its output. If catchall is true, exceptions are catched and returned as HTTPError(500) objects. """ if not self.serve: return HTTPError(503, "Server stopped") try: handler, args = self.match(environ) return handler(**args) except HTTPResponse, e: return e except Exception, e: if isinstance(e, (KeyboardInterrupt, SystemExit, MemoryError))\ or not self.catchall: raise return HTTPError(500, 'Unhandled exception', e, format_exc(10))
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port, _quiet=self.quiet, **self.options)
def run(self, handler): # pragma: no cover from paste import httpserver from paste.translogger import TransLogger handler = TransLogger(handler, setup_console_handler=(not self.quiet)) httpserver.serve(handler, host=self.host, port=str(self.port), **self.options)
def main(): from paste import httpserver httpserver.serve(app, host='127.0.0.1', port='8081')
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port)
def paste(app, address, **options): options = {} from paste import httpserver from paste.translogger import TransLogger httpserver.serve(app, host=address[0], port=address[1], **options)
def waitress(app, address, **options): from waitress import serve serve(app, host=address[0], port=address[1], _quiet=True)
def run(self, handler): # pragma: no cover from paste import httpserver if not self.quiet: from paste.translogger import TransLogger handler = TransLogger(handler) httpserver.serve(handler, host=self.host, port=str(self.port), **self.options)
def __init__(self, catchall=True, autojson=True, config=None): """ Create a new bottle instance. You usually don't do that. Use `bottle.app.push()` instead. """ self.routes = Router() self.mounts = {} self.error_handler = {} self.catchall = catchall self.config = config or {} self.serve = True self.castfilter = [] if autojson and json_dumps: self.add_filter(dict, dict2json) self.hooks = {'before_request': [], 'after_request': []}
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port, _quiet=self.quiet)