Esempio n. 1
0
def serve(ip_address='0.0.0.0', port=8000, profile=False, no_reload=False, no_threading=False, site=None, sites_path='.'):
	global application, _site, _sites_path
	_site = site
	_sites_path = sites_path

	from werkzeug.serving import run_simple

	if profile:
		application = ProfilerMiddleware(application, sort_by=('cumtime', 'calls'))

	if not os.environ.get('NO_STATICS'):
		application = SharedDataMiddleware(application, {
			str('/assets'): str(os.path.join(sites_path, 'assets'))
		})

		application = StaticDataMiddleware(application, {
			str('/files'): str(os.path.abspath(sites_path))
		})

	application.debug = True
	application.config = {
		'SERVER_NAME': 'localhost:8000'
	}

	in_test_env = os.environ.get('CI')
	if in_test_env:
		log = logging.getLogger('werkzeug')
		log.setLevel(logging.ERROR)

	# pcon - Make this a variable, so you can change between 0.0.0.0, or 127.0.0.1, or whatever you want.
	run_simple(ip_address, int(port), application,
		use_reloader=False if in_test_env else not no_reload,
		use_debugger=not in_test_env,
		use_evalex=not in_test_env,
		threaded=not no_threading)
Esempio n. 2
0
def serve(port=8000,
          profile=False,
          no_reload=False,
          no_threading=False,
          site=None,
          sites_path="."):
    global application, _site, _sites_path
    _site = site
    _sites_path = sites_path

    from werkzeug.serving import run_simple

    patch_werkzeug_reloader()

    if profile:
        application = ProfilerMiddleware(application,
                                         sort_by=("cumtime", "calls"))

    if not os.environ.get("NO_STATICS"):
        application = SharedDataMiddleware(
            application,
            {str("/assets"): str(os.path.join(sites_path, "assets"))})

        application = StaticDataMiddleware(
            application, {str("/files"): str(os.path.abspath(sites_path))})

    application.debug = True
    application.config = {"SERVER_NAME": "localhost:8000"}

    log = logging.getLogger("werkzeug")
    log.propagate = False

    in_test_env = os.environ.get("CI")
    if in_test_env:
        log.setLevel(logging.ERROR)

    run_simple(
        "0.0.0.0",
        int(port),
        application,
        use_reloader=False if in_test_env else not no_reload,
        use_debugger=not in_test_env,
        use_evalex=not in_test_env,
        threaded=not no_threading,
    )
Esempio n. 3
0
def serve(port=8000,
          profile=False,
          no_reload=False,
          no_threading=False,
          site=None,
          sites_path='.'):
    global application, _site, _sites_path
    _site = site
    _sites_path = sites_path

    from werkzeug.serving import run_simple
    patch_werkzeug_reloader()

    if profile or os.environ.get('USE_PROFILER'):
        application = ProfilerMiddleware(application,
                                         sort_by=('cumtime', 'calls'))

    if not os.environ.get('NO_STATICS'):
        application = SharedDataMiddleware(
            application,
            {str('/assets'): str(os.path.join(sites_path, 'assets'))})

        application = StaticDataMiddleware(
            application, {str('/files'): str(os.path.abspath(sites_path))})

    application.debug = True
    application.config = {'SERVER_NAME': 'localhost:8000'}

    log = logging.getLogger('werkzeug')
    log.propagate = False

    in_test_env = os.environ.get('CI')
    if in_test_env:
        log.setLevel(logging.ERROR)

    run_simple('0.0.0.0',
               int(port),
               application,
               use_reloader=False if in_test_env else not no_reload,
               use_debugger=not in_test_env,
               use_evalex=not in_test_env,
               threaded=not no_threading)