本文整理汇总了Python中waitress.serve函数的典型用法代码示例。如果您正苦于以下问题:Python serve函数的具体用法?Python serve怎么用?Python serve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serve函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-w', '--waitress', action='store_true')
args = parser.parse_args()
config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "pywps.cfg")
processes = [
FeatureCount(),
SayHello(),
Centroids(),
UltimateQuestion(),
Sleep(),
Buffer(),
Area(),
Viewshed()
]
s = Server(processes=processes, config_file=config_file)
# TODO: need to spawn a different process for different server
if args.waitress:
import waitress
from pywps import configuration
configuration.load_configuration(config_file)
host = configuration.get_config_value('wps', 'serveraddress').split('://')[1]
port = int(configuration.get_config_value('wps', 'serverport'))
waitress.serve(s.app, host=host, port=port)
else:
s.run()
开发者ID:keceke,项目名称:pywps,代码行数:34,代码来源:demo.py
示例2: server_command
def server_command(args):
repository = args.repository
app.config.update(REPOSITORY=repository, SESSION_ID=args.session_id)
app.debug = args.debug
if args.no_worker:
app.config.update(USE_WORKER=False)
if args.profile:
try:
from linesman.middleware import make_linesman_middleware
except ImportError:
print('-P/--profile/--linesman option is available only when '
"linesman is installed", file=sys.stderr)
print('Try the following command:', file=sys.stderr)
print('\tpip install linesman', file=sys.stderr)
raise SystemExit
else:
print('Profiler (linesman) is available:',
'http://{0.host}:{0.port}/__profiler__/'.format(args))
app.wsgi_app = make_linesman_middleware(app.wsgi_app)
if args.debug:
app.wsgi_app = SassMiddleware(app.wsgi_app, {
'earthreader.web': ('static/scss/', 'static/css/')
})
app.run(host=args.host, port=args.port, debug=args.debug,
threaded=True)
else:
serve(app, host=args.host, port=args.port)
开发者ID:Kjwon15,项目名称:earthreader-web,代码行数:27,代码来源:command.py
示例3: start
def start(args, kill = None):
config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "pywps.cfg")
processes = [
FeatureCount(),
SayHello(),
Centroids(),
UltimateQuestion(),
Sleep(),
Buffer(),
Area(),
Box(),
Warp()
]
s = Server(processes=processes, config_file=config_file)
# TODO: need to spawn a different process for different server
if args.waitress:
import waitress
from pywps import configuration
configuration.load_configuration(config_file)
host = configuration.get_config_value('wps', 'serveraddress').split('://')[1]
port = int(configuration.get_config_value('wps', 'serverport'))
waitress.serve(s.app, host=host, port=port)
else:
s.run()
开发者ID:jachym,项目名称:pywps-4-demo,代码行数:29,代码来源:demo.py
示例4: takedown_app
def takedown_app(env, parsed_ns):
try:
from waitress import serve
except ImportError:
print("Waitress needed to run this script")
raise
_waitress_console_logging()
config = Configurator()
config.include('pyramid_chameleon')
msg = "We'll be back shortly. Sorry for the inconvenience!"
if parsed_ns.message:
msg = parsed_ns.message.decode('utf-8')
#Figure out template path
if ':' in parsed_ns.template or parsed_ns.template.startswith('/'):
tpl = parsed_ns.template
else:
#Expect relative path
tpl = os.path.join(os.getcwd(), parsed_ns.template)
view = TakedownView(msg, tpl)
#Test rendering to cause exception early
view(env['request'])
print ("Serving template from: %s" % tpl)
takedown_view = TakedownView(msg, tpl)
config.add_view(takedown_view, context=HTTPNotFound)
print("Takedown app running... press ctrl+c to quit")
app = config.make_wsgi_app()
#Figure out port or socket
kwargs = {}
if ':' in parsed_ns.listen:
kwargs['listen'] = parsed_ns.listen
else:
kwargs['unix_socket'] = parsed_ns.listen
kwargs['unix_socket_perms'] = '666'
serve(app, **kwargs)
开发者ID:ArcheProject,项目名称:Arche,代码行数:34,代码来源:takedown.py
示例5: main
def main():
api = falcon.API()
api.add_route('/heka', HekaEndPoint())
serve(api, host='0.0.0.0', port=6227, _quiet=False)
开发者ID:mabotech,项目名称:mabo.io,代码行数:7,代码来源:falcon_server.py
示例6: main
def main():
insta = Instagram()
recent_instagrams = insta.recent_images()
app = create_app()
serve(app, port=9845)
开发者ID:gcarothers,项目名称:acidfree,代码行数:6,代码来源:__init__.py
示例7: serve
def serve(self, host='0.0.0.0', port=8080):
"""
Launch the WSGI app development web server
"""
import waitress
logger.info("{}:{}".format(host, port))
waitress.serve(self.app, host=host, port=port, _quiet=True)
开发者ID:ialbert,项目名称:pyblue-central,代码行数:7,代码来源:engine.py
示例8: run
def run():
if len(sys.argv) != 2:
sys.stderr.write("Usage: %s <config_file>\n" % (sys.argv[0],))
sys.exit(1)
settings = {'db_filename': './acss.db', 'server_host': 'localhost',
'server_port': 8081}
settings.update(json.loads(open(sys.argv[1]).read()))
config = Configurator(settings=settings)
def add_db(request, reify=True):
return DB(request.registry.settings.get('db_filename'))
config.add_request_method(add_db, 'db')
config.add_route('api_tracks', '/api/tracks')
config.add_route('api_track_bestlaps', '/api/tracks/{track_name}/bestlaps')
config.add_route('api_track_bestlaps_with_cars', '/api/tracks/{track_name}/{car_names}/bestlaps')
config.add_route('api_server_info', '/api/server_info')
config.add_view(api_tracks, route_name='api_tracks', renderer='json')
config.add_view(api_track_bestlaps, route_name='api_track_bestlaps',
renderer='json')
config.add_view(api_track_bestlaps_with_cars,
route_name='api_track_bestlaps_with_cars', renderer='json')
config.add_view(api_server_info, route_name='api_server_info',
renderer='json')
app = config.make_wsgi_app()
serve(app, host='0.0.0.0', port=8001)
开发者ID:joaoubaldo,项目名称:assetto_corsa_stats_service,代码行数:31,代码来源:wsgi_service.py
示例9: Main
def Main():
args = ParseArguments()
if args.stdout is not None:
sys.stdout = open( args.stdout, 'w' )
if args.stderr is not None:
sys.stderr = open( args.stderr, 'w' )
SetupLogging( args.log )
options = SetupOptions( args.options_file )
# This ensures that ycm_core is not loaded before extra conf
# preload was run.
YcmCoreSanityCheck()
extra_conf_store.CallGlobalExtraConfYcmCorePreloadIfExists()
PossiblyDetachFromTerminal()
# This can't be a top-level import because it transitively imports
# ycm_core which we want to be imported ONLY after extra conf
# preload has executed.
from ycmd import handlers
handlers.UpdateUserOptions( options )
SetUpSignalHandler(args.stdout, args.stderr, args.keep_logfiles)
handlers.app.install( WatchdogPlugin( args.idle_suicide_seconds ) )
handlers.app.install( HmacPlugin( options[ 'hmac_secret' ] ) )
CloseStdin()
waitress.serve( handlers.app,
host = args.host,
port = args.port,
threads = 30 )
开发者ID:arakashic,项目名称:ycmd,代码行数:30,代码来源:__main__.py
示例10: main
def main():
parser = argparse.ArgumentParser(
description=('Command-line interface for running the '
'RasmusMediaWeb server'),
)
parser.add_argument(
'-p', '--port',
default='8888',
help='Port to listen on (default: 8888)',
)
parser.add_argument(
'-i', '--interface',
default='0.0.0.0',
help='Interface to listen on (default: 0.0.0.0)',
)
parser.add_argument(
'--prefix',
help='Serve app at a prefixed url',
)
args = parser.parse_args()
kwargs = {
'host': args.interface,
'port': args.port,
}
if args.prefix:
kwargs['url_prefix'] = args.prefix
serve(make_app(), **kwargs)
开发者ID:sylvesterernie,项目名称:RasmusMediaWeb,代码行数:29,代码来源:server.py
示例11: server
def server(reload=False):
"Run the server"
if reload:
reload_me("server")
else:
serve(app, host=app.config["HOST"], port=app.config["PORT"],
threads=app.config["THREADS"])
开发者ID:puffinrocks,项目名称:puffin,代码行数:7,代码来源:puffin.py
示例12: run
def run(self, host='127.0.0.1', port=5000):
from waitress import serve
try:
serve(self, host=host, port=port)
except Exception as e:
raise RuntimeError("Unable to start server on "
"{}:{} ({})".format(host, port, e))
开发者ID:alongyaa,项目名称:framework,代码行数:7,代码来源:framework.py
示例13: wsgi_run
def wsgi_run(app, opts, args):
""" """
serve(app,
host=opts.host,
port=opts.port
)
开发者ID:ishanm,项目名称:rhaptos2.repo,代码行数:7,代码来源:run.py
示例14: api_server
def api_server(ctx, bind, workers):
"""
Starts the nidaba API server using gunicorn.
"""
try:
from nidaba import api
from nidaba import web
except IOError as e:
if e.errno == 2:
click.echo('No configuration file found at {}'.format(e.filename))
ctx.exit()
import logging
from waitress import serve
from flask import Flask
logging.basicConfig(level=logging.DEBUG)
app = Flask('nidaba')
app.register_blueprint(api.get_blueprint())
app.register_blueprint(web.get_blueprint())
serve(app, listen=' '.join(bind).encode('utf-8'), threads=workers)
开发者ID:OpenPhilology,项目名称:nidaba,代码行数:25,代码来源:cli.py
示例15: run_server
def run_server(config):
setup_app(config)
setup_logging(config)
# Initialize huey task queue
global task_queue
db_location = os.path.join(config.config_dir(), 'queue.db')
task_queue = SqliteHuey(location=db_location)
consumer = Consumer(task_queue)
ip_address = get_ip_address()
if (app.config['standalone'] and ip_address
and config['driver'].get() in ['chdkcamera', 'a2200']):
# Display the address of the web interface on the camera displays
try:
for cam in get_devices(config):
cam.show_textbox(
"\n You can now access the web interface at:"
"\n\n\n http://{0}:5000".format(ip_address))
except:
logger.warn("No devices could be found at startup.")
# Start task consumer
consumer.start()
try:
import waitress
# NOTE: We spin up this obscene number of threads since we have
# some long-polling going on, which will always block
# one worker thread.
waitress.serve(app, port=5000, threads=16)
finally:
consumer.shutdown()
if app.config['DEBUG']:
logger.info("Waiting for remaining connections to close...")
开发者ID:atomotic,项目名称:spreads,代码行数:34,代码来源:__init__.py
示例16: run_server
def run_server(f, port):
global folder_to_save_data, port_for_server
if f != None:
folder_to_save_data = abspath(f)
if port != None:
port_for_server = port
print("\n\nStarting server, saving data to %s" % folder_to_save_data)
serve(app, listen='*:' + port_for_server)
开发者ID:Alex-Cynet,项目名称:playlistfromsong,代码行数:8,代码来源:server.py
示例17: run
def run(self):
bottle_app = bottle.app()
# Initialize the app context
app_context = [ApiController()]
# Serve the api
waitress.serve(bottle_app, host='0.0.0.0', port=8080)
开发者ID:brettvitaz,项目名称:relevantxkcd,代码行数:8,代码来源:app.py
示例18: main
def main():
engine = sqlalchemy.create_engine('sqlite:///morepath_react.db')
Session.configure(bind=engine)
Base.metadata.create_all(engine)
Base.metadata.bind = engine
morepath.autosetup()
app = App()
waitress.serve(app)
开发者ID:faassen,项目名称:morepath_react,代码行数:9,代码来源:main.py
示例19: serve_app
def serve_app(parser, args):
app = spline.app.main({}, **vars(args))
if args.bind:
import waitress
waitress.serve(app, **args.bind)
else:
# TODO this is for playing nicely with uwsgi's paste-serve, but will
# just quietly exit if you run directly as CLI, oops?
return app
开发者ID:eevee,项目名称:spline,代码行数:9,代码来源:run.py
示例20: server_command
def server_command(args):
repository = args.repository
app.config.update(REPOSITORY=repository, SESSION_ID=args.session_id)
app.debug = args.debug
spawn_worker()
if args.debug:
app.run(host=args.host, port=args.port, debug=args.debug, threaded=True)
else:
serve(app, host=args.host, port=args.port)
开发者ID:0hoo,项目名称:web,代码行数:9,代码来源:command.py
注:本文中的waitress.serve函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论