本文整理汇总了Python中werkzeug.run_simple函数的典型用法代码示例。如果您正苦于以下问题:Python run_simple函数的具体用法?Python run_simple怎么用?Python run_simple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_simple函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_server
def run_server(hostname='localhost', port=8080,
docs=True,
debug='off',
user=None, group=None,
threaded=True,
**kw):
""" Run a standalone server on specified host/port. """
application = make_application(shared=docs)
if port < 1024:
if os.name == 'posix' and os.getuid() != 0:
raise RuntimeError('Must run as root to serve port number under 1024. '
'Run as root or change port setting.')
if user:
switch_user(user, group)
if debug == 'external':
# no threading is better for debugging, the main (and only)
# thread then will just terminate when an exception happens
threaded = False
run_simple(hostname=hostname, port=port,
application=application,
threaded=threaded,
use_debugger=(debug == 'web'),
passthrough_errors=(debug == 'external'),
request_handler=RequestHandler,
**kw)
开发者ID:Glottotopia,项目名称:aagd,代码行数:29,代码来源:serving.py
示例2: inner_run
def inner_run():
print "Validating models..."
self.validate(display_num_errors=True)
print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
print "Development server is running at http://%s:%s/" % (addr, port)
print "Using the Werkzeug debugger (http://werkzeug.pocoo.org/)"
print "Quit the server with %s." % quit_command
path = options.get('admin_media_path', '')
if not path:
admin_media_path = os.path.join(django.__path__[0], 'contrib/admin/static/admin')
if os.path.isdir(admin_media_path):
path = admin_media_path
else:
path = os.path.join(django.__path__[0], 'contrib/admin/media')
handler = WSGIHandler()
if USE_ADMINMEDIAHANDLER:
handler = AdminMediaHandler(handler, path)
if USE_STATICFILES:
use_static_handler = options.get('use_static_handler', True)
insecure_serving = options.get('insecure_serving', False)
if use_static_handler and (settings.DEBUG or insecure_serving):
handler = StaticFilesHandler(handler)
if open_browser:
import webbrowser
url = "http://%s:%s/" % (addr, port)
webbrowser.open(url)
run_simple(addr, int(port), DebuggedApplication(handler, True),
use_reloader=use_reloader, use_debugger=True, threaded=threaded)
开发者ID:2flcastro,项目名称:ka-lite,代码行数:28,代码来源:runserver_plus.py
示例3: main
def main():
wsgihandler = getwsgihandler(debug=True)
bind_address = "127.0.0.1"
port = 5000
werkzeug.run_simple(
bind_address, port, wsgihandler, use_debugger=True, use_reloader=True
)
开发者ID:bjornua,项目名称:simpleweb,代码行数:7,代码来源:wsgiapp.py
示例4: main
def main():
app = Main(debug=True)
bind_address = "127.0.0.1"
port = 5000
run_simple(
bind_address, port, app, use_debugger=True, use_reloader=True
)
开发者ID:bjornua,项目名称:collectd-reader,代码行数:7,代码来源:dev-server.py
示例5: standalone_serve
def standalone_serve():
"""Standalone WSGI Server for debugging purposes"""
from werkzeug import run_simple
import logging
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False)
(options, args) = parser.parse_args()
if options.verbose:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.ERROR)
port = 8080
if len(args) > 0:
port = int(args[0])
app = create_application()
#from werkzeugprofiler import ProfilerMiddleware
#app = ProfilerMiddleware(app, stream=open('profile_stats.txt', 'w'), accum_count=100, sort_by=('cumulative', 'calls'), restrictions=(.1,))
run_simple('0.0.0.0', port, app, use_reloader=True,
use_debugger=True, #use_evalex=True,
)
开发者ID:Readon,项目名称:cydra,代码行数:27,代码来源:__init__.py
示例6: inner_run
def inner_run():
# Flag the server as active
from devserver import settings
import devserver
settings.DEVSERVER_ACTIVE = True
settings.DEBUG = True
from django.conf import settings
from django.utils import translation
print "Validating models..."
self.validate(display_num_errors=True)
print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
print "Running django-devserver %s" % (devserver.get_version(),)
print "Development server is running at http://%s:%s/" % (addr, port)
print "Quit the server with %s." % quit_command
# django.core.management.base forces the locale to en-us. We should
# set it up correctly for the first request (particularly important
# in the "--noreload" case).
translation.activate(settings.LANGUAGE_CODE)
if int(options["verbosity"]) < 1:
base_handler = WSGIHandler
else:
base_handler = DevServerHandler
if options["use_forked"]:
mixin = SocketServer.ForkingMixIn
else:
mixin = SocketServer.ThreadingMixIn
try:
handler = AdminMediaHandler(base_handler(), admin_media_path)
if use_werkzeug:
run_simple(
addr,
int(port),
DebuggedApplication(handler, True),
use_reloader=use_reloader,
use_debugger=True,
)
else:
run(addr, int(port), handler, mixin)
except WSGIServerException, e:
# Use helpful error messages instead of ugly tracebacks.
ERRORS = {
13: "You don't have permission to access that port.",
98: "That port is already in use.",
99: "That IP address can't be assigned-to.",
}
try:
error_text = ERRORS[e.args[0].args[0]]
except (AttributeError, KeyError):
error_text = str(e)
sys.stderr.write(self.style.ERROR("Error: %s" % error_text) + "\n")
# Need to use an OS exit because sys.exit doesn't work in a thread
os._exit(1)
开发者ID:kmill,项目名称:squidmusic,代码行数:59,代码来源:runserver.py
示例7: profile_run
def profile_run():
from werkzeug import run_simple
from werkzeug.contrib.profiler import ProfilerMiddleware, MergeStream
print "* Profiling"
f = open('./profiler.log', 'w')
profiled_app = ProfilerMiddleware(app, MergeStream(sys.stderr, f))
run_simple('localhost', 5000, profiled_app,
use_reloader=True, use_debugger=True)
开发者ID:GregMeno,项目名称:kardboard,代码行数:8,代码来源:runserver.py
示例8: run
def run(handler, host='0.0.0.0', port=8000, use_reloader=False,
use_debugger=False, use_evalex=True, extra_files=None,
reloader_interval=1, threaded=False, processes=1, request_handler=None,
passthrough_errors=False):
'''create a server instance and run it'''
werkzeug.run_simple(host, port, handler, use_reloader, use_debugger,
use_evalex, extra_files, reloader_interval, threaded, processes,
request_handler, handler.static_paths, passthrough_errors)
开发者ID:mcaudy,项目名称:tubes,代码行数:8,代码来源:tubes.py
示例9: development_server
def development_server():
app_path = os.path.basename(__file__)
werkzeug.run_simple('', 8000,
util.wrap_static(application, app_path,
index='wakaba.html',
not_found_handler=app.not_found),
use_reloader=True, use_debugger=config.DEBUG)
开发者ID:k-anon,项目名称:wakarimasen,代码行数:8,代码来源:wakarimasen.py
示例10: handle
def handle(self, **options):
if import_excpetion:
print "Get werkzeug module form http://werkzeug.pocoo.org/download"
raise SystemExit
run_simple(
options["ip"], int(options["port"]),
DebuggedApplication(WSGIHandler(), True)
)
开发者ID:amitu,项目名称:dutils,代码行数:8,代码来源:rdebug.py
示例11: run
def run(self):
"""Start the debugger"""
def setup_func():
self.setup_500()
self.setup_path(self.project)
app = self.setup_app()
run_simple(self.host, self.port, app
, use_debugger=True, use_reloader=True, setup_func=setup_func
)
开发者ID:areski,项目名称:cwf,代码行数:9,代码来源:debugger.py
示例12: main
def main():
logging.basicConfig(level=logging.INFO)
import yaml
config = yaml.load(open("config.yaml", "r"))
app = RESTfulWebService(config)
from werkzeug import run_simple
run_simple(config.get("server", "140.134.26.21"), config.get("port", 7788), app)
开发者ID:takuro1026,项目名称:iFCU,代码行数:9,代码来源:restfulws.py
示例13: profile_run
def profile_run():
print "* Profiling"
f = open('./profiler.log', 'w')
profiled_app = ProfilerMiddleware(app, MergeStream(sys.stderr, f))
run_simple(app.config['SERVER_LISTEN'],
app.config['SERVER_PORT'],
profiled_app,
use_reloader=app.config['DEBUG'],
use_debugger=app.config['DEBUG'])
开发者ID:shaunduncan,项目名称:breezeminder,代码行数:9,代码来源:runserver.py
示例14: debug
def debug(host='0.0.0.0', port=8976):
""" """
# This is only needed for Django versions < [7537]:
def null_technical_500_response(request, exc_type, exc_value, tb):
raise exc_type, exc_value, tb
from django.views import debug
debug.technical_500_response = null_technical_500_response
os.environ['DJANGO_SETTINGS_MODULE'] = 'agenda.production'
run_simple(host, port, DebuggedApplication(WSGIHandler(), True))
开发者ID:BeyondLab,项目名称:agendadulibre,代码行数:11,代码来源:command.py
示例15: inner_run
def inner_run():
from django.conf import settings
print "Validating models..."
self.validate(display_num_errors=True)
print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
print "Development server is running at http://%s:%s/" % (addr, port)
print "Using the Werkzeug debugger (http://werkzeug.pocoo.org/)"
print "Quit the server with %s." % quit_command
path = admin_media_path or django.__path__[0] + '/contrib/admin/media'
handler = AdminMediaHandler(WSGIHandler(), path)
run_simple(addr, int(port), DebuggedApplication(handler, True),
use_reloader=use_reloader, use_debugger=True)
开发者ID:HughP,项目名称:rapidsms,代码行数:12,代码来源:runserver_plus.py
示例16: simple_server
def simple_server(host='127.0.0.1', port=8080, use_reloader=False):
"""Run a simple server for development purpose.
:param host: host name
:param post: port number
:param use_reloader: whether to reload the server if any of the loaded
module changed.
"""
from werkzeug import run_simple
# create a wsgi application
app = Application()
run_simple(host, port, app, use_reloader=use_reloader, use_debugger=app.debug)
开发者ID:cloudappsetup,项目名称:kalapy,代码行数:12,代码来源:app.py
示例17: inner_run
def inner_run():
print "Validating models..."
self.validate(display_num_errors=True)
print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
print "Development server is running at http://%s:%s/" % (addr, port)
print "Using the Werkzeug debugger (http://werkzeug.pocoo.org/)"
print "Quit the server with %s." % quit_command
path = options.get('admin_media_path', '')
if not path:
admin_media_path = os.path.join(django.__path__[0], 'contrib/admin/static/admin')
if os.path.isdir(admin_media_path):
path = admin_media_path
else:
path = os.path.join(django.__path__[0], 'contrib/admin/media')
handler = WSGIHandler()
if USE_ADMINMEDIAHANDLER:
handler = AdminMediaHandler(handler, path)
if USE_STATICFILES:
use_static_handler = options.get('use_static_handler', True)
insecure_serving = options.get('insecure_serving', False)
if use_static_handler and (settings.DEBUG or insecure_serving):
handler = StaticFilesHandler(handler)
if open_browser:
import webbrowser
url = "http://%s:%s/" % (addr, port)
webbrowser.open(url)
if cert_path:
try:
from werkzeug.serving import make_ssl_devcert
ssl_context = make_ssl_devcert(cert_path, host='localhost')
run_simple(
addr,
int(port),
DebuggedApplication(handler, True),
use_reloader=use_reloader,
use_debugger=True,
threaded=threaded,
ssl_context=ssl_context
)
except ImportError:
raise CommandError("""Werkzeug 0.8.2 or later is required
to use runserver_plus with ssl support. Please
visit http://werkzeug.pocoo.org/download""")
else:
run_simple(
addr,
int(port),
DebuggedApplication(handler, True),
use_reloader=use_reloader,
use_debugger=True,
threaded=threaded
)
开发者ID:hfeeki,项目名称:django-extensions,代码行数:52,代码来源:runserver_plus.py
示例18: http
def http(application, host='', port=8000):
"""
$0 http [host [port]]
Defaults to listening on all interfaces, port 8000
"""
app_path = os.path.basename(sys.argv[0])
werkzeug.run_simple(host, int(port),
util.wrap_static(application, app_path,
index='wakaba.html'),
use_reloader=True, use_debugger=config.DEBUG)
开发者ID:dequis,项目名称:wakarimasen,代码行数:13,代码来源:cli.py
示例19: development
def development(addr, port, application):
from werkzeug import run_simple
run_simple(
addr,
port,
application,
use_reloader=True,
extra_files=None,
reloader_interval=1,
threaded=False,
processes=1,
request_handler=None,
)
开发者ID:ariessa,项目名称:coverart_redirect,代码行数:14,代码来源:coverart_redirect_server.py
示例20: run
def run(self):
from werkzeug import run_simple
def wsgi_app(*a):
from solace.application import application
return application(*a)
# werkzeug restarts the interpreter with the same arguments
# which would print "running runserver" a second time. Because
# of this we force distutils into quiet mode.
import sys
sys.argv.insert(1, '-q')
run_simple(self.host, int(self.port), wsgi_app,
use_reloader=not self.no_reloader,
use_debugger=not self.no_debugger)
开发者ID:burhan,项目名称:solace,代码行数:15,代码来源:scripts.py
注:本文中的werkzeug.run_simple函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论