Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
yield "data: %s\n\n" % json.dumps({"clear":True})
for bird in birds:
yield "data: %s\n\n" % json.dumps({"update":bird})
# Send incremental updates as they happen.
while cherrypy.engine.state == cherrypy.engine.states.STARTED:
try:
operation = queue.get(timeout=2.0)
yield "data: %s\n\n" % operation
except:
yield ":\n\n"
cherrypy.log.error("Stopping birds handler.")
return content()
birds._cp_config = {"response.stream": True}
cherrypy.quickstart(Root(), '/', config={
"/js" : {
"tools.staticdir.dir" : os.path.abspath("js"),
"tools.staticdir.on" : True,
}
with open(mapper_file_name) as f:
mappers += f.read()
return mappers
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('environment', type=str, help="Must be either 'production' or 'development'")
args = parser.parse_args()
if args.environment == 'production':
cherrypy.config.update(PRODUCTION_SERVER_CONFIG)
cherrypy.quickstart(RepoGrams(), config=PRODUCTION_INSTANCE_CONFIG)
elif args.environment == 'development':
cherrypy.config.update(DEVELOPMENT_SERVER_CONFIG)
cherrypy.tree.mount(RepoGrams(), '/app', DEVELOPMENT_INSTANCE_CONFIG_APP)
cherrypy.quickstart(config=DEVELOPMENT_INSTANCE_CONFIG_STATIC)
else:
parser.error("Unknown environment: %s" % args.environment)
if 'ssl_crt' not in apiopts or 'ssl_key' not in apiopts:
logger.error("Not starting '%s'. Options 'ssl_crt' and "
"'ssl_key' are required if SSL is not disabled.",
__name__)
return None
verify_certs(apiopts['ssl_crt'], apiopts['ssl_key'])
cherrypy.server.ssl_module = 'builtin'
cherrypy.server.ssl_certificate = apiopts['ssl_crt']
cherrypy.server.ssl_private_key = apiopts['ssl_key']
if 'ssl_chain' in apiopts.keys():
cherrypy.server.ssl_certificate_chain = apiopts['ssl_chain']
cherrypy.quickstart(root, apiopts.get('root_prefix', '/'), conf)
else:
if name is None:
# No name was specified
return 'Please enter your name <a href="./">here</a>.'
else:
return 'No, really, enter your name <a href="./">here</a>.'
import os.path
tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf')
if __name__ == '__main__':
# CherryPy always starts with app.root when trying to map request URIs
# to objects, so we need to mount a request handler root. A request
# to '/' will be mapped to HelloWorld().index().
cherrypy.quickstart(WelcomePage(), config=tutconf)
return { 'bug_root': args[0], }
config = path.join(module_dir, 'cfbe.config')
options = parse_arguments()
WebInterface = web.WebInterface(path.abspath(options['bug_root']), template_dir)
cherrypy.config.update({
'tools.encode.on': True,
'tools.encode.encoding': 'utf8',
'tools.staticdir.root': path.join(module_dir, 'static'),
})
app_config = { '/static': { 'tools.staticdir.on': True,
'tools.staticdir.dir': '', } }
cherrypy.quickstart(WebInterface, '/', app_config)
def run(self):
print "PROCS: %s" % os.environ.get('NUMBER_OF_PROCESSORS')
app = cherrypy.Application(None, config=myconfig)
cherrypy.quickstart(app, config=myconfig)
cherrypy.engine.block()
def serve(path=localFile, port=8080, root=None):
if coverage is None:
raise ImportError('The coverage module could not be imported.')
from coverage import coverage
cov = coverage(data_file=path)
cov.load()
cherrypy.config.update({'server.socket_port': int(port),
'server.thread_pool': 10,
'environment': 'production',
})
cherrypy.quickstart(CoverStats(cov, root))