Esempio n. 1
0
def serve(port=8000, profile=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, {
			b'/assets': os.path.join(sites_path, 'assets').encode("utf-8"),
		})

		application = StaticDataMiddleware(application, {
			b'/files': os.path.abspath(sites_path).encode("utf-8")
		})

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

	run_simple('0.0.0.0', int(port), application, use_reloader=True,
		use_debugger=True, use_evalex=True, threaded=True)
Esempio n. 2
0
def serve(port=8000, profile=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, {
			'/assets': os.path.join(sites_path, 'assets'),
		})

		application = StaticDataMiddleware(application, {
			'/files': 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)

	run_simple('0.0.0.0', int(port), application,
		use_reloader=not in_test_env,
		use_debugger=not in_test_env,
		use_evalex=not in_test_env,
		threaded=True)
Esempio n. 3
0
File: app.py Progetto: Eddiy/frappe
def serve(port=8000, profile=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, {
                '/assets': os.path.join(sites_path, 'assets'),
            })

        application = StaticDataMiddleware(
            application, {'/files': 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)

    run_simple('0.0.0.0',
               int(port),
               application,
               use_reloader=not in_test_env,
               use_debugger=not in_test_env,
               use_evalex=not in_test_env,
               threaded=True)
Esempio n. 4
0
def serve(port=8000, profile=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=('tottime', 'calls'))

	if not os.environ.get('NO_STATICS'):
		application = SharedDataMiddleware(application, {
			b'/assets': os.path.join(sites_path, 'assets').encode("utf-8"),
		})

		application = StaticDataMiddleware(application, {
			b'/files': os.path.abspath(sites_path).encode("utf-8")
		})

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

	run_simple('0.0.0.0', int(port), application, use_reloader=True,
		use_debugger=True, use_evalex=True, threaded=True)
Esempio n. 5
0
def serve(port=8000, profile=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=("tottime", "calls"))

    if not os.environ.get("NO_STATICS"):
        application = SharedDataMiddleware(
            application, {b"/assets": os.path.join(sites_path, "assets").encode("utf-8")}
        )

        application = StaticDataMiddleware(application, {b"/files": os.path.abspath(sites_path).encode("utf-8")})

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

    run_simple("0.0.0.0", int(port), application, use_reloader=True, use_debugger=True, use_evalex=True, threaded=True)