Python paste.httpserver.serve() Examples
The following are 30
code examples of paste.httpserver.serve().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
paste.httpserver
, or try the search function
.
Example #1
Source File: mishkal-webserver.py From mishkal with GNU General Public License v3.0 | 6 votes |
def test(): # this requires python-paste package import logging from paste import httpserver d=fromFs(os.path.dirname(sys.argv[0])) LOG_FILENAME = os.path.join(d,u'tmp','logging_example.out') logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO,) myLogger=logging.getLogger('MyTestWebApp') h=logging.StreamHandler() # in production use WatchedFileHandler or RotatingFileHandler h.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")) myLogger.addHandler(h) myLogger.setLevel(logging.INFO) # in production use logging.INFO d=fromFs(os.path.dirname(sys.argv[0])) app=webApp( os.path.join(d,u'resources/templates'), staticBaseDir={u'/_files/':os.path.join(d,u'resources/files')}, logger=myLogger ); # for options see http://pythonpaste.org/modules/httpserver.html try: httpserver.serve(app, host='0.0.0.0', port='8080') except: httpserver.serve(app, host='0.0.0.0', port='8081')
Example #2
Source File: bottle.py From props with MIT License | 6 votes |
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': []}
Example #3
Source File: api.py From freezer-api with Apache License 2.0 | 6 votes |
def main(): # setup opts config.parse_args(args=sys.argv[1:]) config.setup_logging() paste_conf = config.find_paste_config() # quick simple server for testing purposes or simple scenarios ip = CONF.get('bind_host', '0.0.0.0') port = CONF.get('bind_port', 9090) try: httpserver.serve( application=deploy.loadapp('config:%s' % paste_conf, name='main'), host=ip, port=port) message = (_i18n._('Server listening on %(ip)s:%(port)s') % {'ip': ip, 'port': port}) _LOG.info(message) print(message) except KeyboardInterrupt: print(_i18n._("Thank You ! \nBye.")) sys.exit(0)
Example #4
Source File: server.py From verejne.digital with Apache License 2.0 | 6 votes |
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() initialise_app() host, port = args.listen.split(':') httpserver.serve( app, host=host, port=port, request_queue_size=128, use_threadpool=True, threadpool_workers=32, )
Example #5
Source File: server.py From verejne.digital with Apache License 2.0 | 6 votes |
def main(): parser = argparse.ArgumentParser() parser.add_argument('--listen', help='host:port to listen on', default='127.0.0.1:8084') args = parser.parse_args() host, port = args.listen.split(':') httpserver.serve( app, host=host, port=port, request_queue_size=128, use_threadpool=True, threadpool_workers=32, )
Example #6
Source File: serving.py From verejne.digital with Apache License 2.0 | 6 votes |
def main(): # Parse command line arguments into `args` dictionary: parser = argparse.ArgumentParser() parser.add_argument('--listen', help='host:port to listen on', default='127.0.0.1:8082') args = parser.parse_args() # Initialise the application: initialise_app() # Start serving requests: host, port = args.listen.split(':') httpserver.serve( app, host=host, port=port, request_queue_size=128, use_threadpool=True, threadpool_workers=32, )
Example #7
Source File: bottle.py From slack-machine with MIT License | 5 votes |
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port, _quiet=self.quiet, **self.options)
Example #8
Source File: bottle.py From opsbro with MIT License | 5 votes |
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)
Example #9
Source File: bottle.py From slack-machine with MIT License | 5 votes |
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)
Example #10
Source File: gnomecast.py From gnomecast with GNU General Public License v3.0 | 5 votes |
def start_server(self): app = self.app @app.route('/subtitles.vtt') def subtitles(): # response = bottle.static_file(self.subtitles_fn, root='/', mimetype='text/vtt') response = bottle.response response.headers['Access-Control-Allow-Origin'] = '*' response.headers['Access-Control-Allow-Methods'] = 'GET, HEAD' response.headers['Access-Control-Allow-Headers'] = 'Content-Type' response.headers['Content-Type'] = 'text/vtt' return self.subtitles @app.get('/media/<id>.<ext>') def video(id, ext): print(list(bottle.request.headers.items())) ranges = list(bottle.parse_range_header(bottle.request.environ['HTTP_RANGE'], 1000000000000)) print('ranges', ranges) offset, end = ranges[0] self.transcoder.wait_for_byte(offset) response = bottle.static_file(self.transcoder.fn, root='/') if 'Last-Modified' in response.headers: del response.headers['Last-Modified'] response.headers['Access-Control-Allow-Origin'] = '*' response.headers['Access-Control-Allow-Methods'] = 'GET, HEAD' response.headers['Access-Control-Allow-Headers'] = 'Content-Type' return response # app.run(host=self.ip, port=self.port, server='paste', daemon=True) from paste import httpserver from paste.translogger import TransLogger handler = TransLogger(app, setup_console_handler=True) httpserver.serve(handler, host=self.ip, port=str(self.port), daemon_threads=True)
Example #11
Source File: bottle.py From POC-EXP with GNU General Public License v3.0 | 5 votes |
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port, _quiet=self.quiet)
Example #12
Source File: bottle.py From props with MIT License | 5 votes |
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
Example #13
Source File: bottle.py From props with MIT License | 5 votes |
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': []}
Example #14
Source File: bottle.py From props with MIT License | 5 votes |
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
Example #15
Source File: bottle.py From props with MIT License | 5 votes |
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)
Example #16
Source File: bottle.py From aws-mock-metadata with MIT License | 5 votes |
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port)
Example #17
Source File: bottle.py From aws-mock-metadata with MIT License | 5 votes |
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)
Example #18
Source File: bottle.py From EasY_HaCk with Apache License 2.0 | 5 votes |
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)
Example #19
Source File: bottle.py From annotated-py-projects with MIT License | 5 votes |
def run(self, handler): # 重写 run() 函数. from paste import httpserver from paste.translogger import TransLogger app = TransLogger(handler) httpserver.serve(app, host=self.host, port=str(self.port))
Example #20
Source File: bottle.py From contrail-server-manager with Apache License 2.0 | 5 votes |
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)
Example #21
Source File: bottle.py From contrail-server-manager with Apache License 2.0 | 5 votes |
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port)
Example #22
Source File: bottle.py From bazarr with GNU General Public License v3.0 | 5 votes |
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)
Example #23
Source File: bottle.py From opsbro with MIT License | 5 votes |
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port)
Example #24
Source File: bottle.py From warriorframework with Apache License 2.0 | 5 votes |
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)
Example #25
Source File: bottle.py From warriorframework with Apache License 2.0 | 5 votes |
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port, _quiet=self.quiet, **self.options)
Example #26
Source File: bottle.py From warriorframework with Apache License 2.0 | 5 votes |
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)
Example #27
Source File: bottle.py From warriorframework with Apache License 2.0 | 5 votes |
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port)
Example #28
Source File: bottle.py From malwareHunter with GNU General Public License v2.0 | 5 votes |
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)
Example #29
Source File: bottle.py From malwareHunter with GNU General Public License v2.0 | 5 votes |
def run(self, handler): from waitress import serve serve(handler, host=self.host, port=self.port)
Example #30
Source File: bottle.py From malwareHunter with GNU General Public License v2.0 | 5 votes |
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)