def main():
if not path.exists(TEMP_PATH):
mkdir(TEMP_PATH)
StoreManager.register(
'fs',
functools.partial(FileSystemStore, TEMP_PATH, 'http://localhost:8080/avatars'),
default=True
)
conf = {
'/': {
'tools.sessions.on': True,
'tools.staticdir.root': WORKING_DIR
},
'/avatars': {
'tools.staticdir.on': True,
'tools.staticdir.dir': TEMP_PATH
}
}
cherrypy.quickstart(Root(), config=conf)
python类quickstart()的实例源码
def main():
find_rop_gadgets('libc.so')
with open('exploit.mp4', 'wb') as tmp:
tmp.write(exploit_mp4())
cherrypy.quickstart(ExploitServer())
def run(self):
conf = { '/': {}}
cherrypy.quickstart(self.__root, '/', conf)
def browser_authorize(self):
"""
Open a browser to the authorization url and spool up a CherryPy
server to accept the response
"""
url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
# Open the web browser in a new thread for command-line browser support
threading.Timer(1, webbrowser.open, args=(url,)).start()
cherrypy.quickstart(self)
def main(db):
conf = {
'/': {
'tools.staticdir.on': True,
'tools.staticdir.dir': os.path.join(
os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
'web'
)
},
}
cherrypy.quickstart(Server(db), '/', conf)
def browser_authorize(self):
"""
Open a browser to the authorization url and spool up a CherryPy
server to accept the response
"""
url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
# Open the web browser in a new thread for command-line browser support
threading.Timer(1, webbrowser.open, args=(url,)).start()
cherrypy.quickstart(self)
def browser_authorize(self):
"""
Open a browser to the authorization url and spool up a CherryPy
server to accept the response
"""
url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
# Open the web browser in a new thread for command-line browser support
threading.Timer(1, webbrowser.open, args=(url,)).start()
cherrypy.config.update({'server.socket_host': '127.0.0.1','server.socket_port': 8000})
cherrypy.quickstart(self)
def run():
# user anonymity is achieved in the laziest possible way: a literal user
# named anonymous. may god have mercy on my soul.
_c = sqlite3.connect(dbname)
try:
db.anon = db.user_resolve(_c, "anonymous")
if not db.anon:
db.anon = db.user_register(
_c, "anonymous", # this is the hash for "anon"
"5430eeed859cad61d925097ec4f53246"
"1ccf1ab6b9802b09a313be1478a4d614")
finally:
_c.close()
cherrypy.quickstart(API(), "/api", API_CONFIG)
def serve(path=None, port=8080):
if profile is None or pstats is None:
msg = ('Your installation of Python does not have a profile module. '
"If you're on Debian, try "
'`sudo apt-get install python-profiler`. '
'See http://www.cherrypy.org/wiki/ProfilingOnDebian '
'for details.')
warnings.warn(msg)
cherrypy.config.update({'server.socket_port': int(port),
'server.thread_pool': 10,
'environment': 'production',
})
cherrypy.quickstart(Profiler(path))
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()
import cherrypy
cherrypy.config.update({'server.socket_port': int(port),
'server.thread_pool': 10,
'environment': 'production',
})
cherrypy.quickstart(CoverStats(cov, root))
def StartAgent(trainer=None,port=8765):
global workout
workout = trainer
cherrypy.config.update({'server.socket_port': port})
WebSocketPlugin(cherrypy.engine).subscribe()
cherrypy.tools.websocket = WebSocketTool()
cherrypy.config.update({'engine.autoreload.on': False})
config = {'/ws': {'tools.websocket.on': True,
'tools.websocket.handler_cls': AgentServer}}
cherrypy.quickstart(Root(), '/', config)
def browser_authorize(self):
"""
Open a browser to the authorization url and spool up a CherryPy
server to accept the response
"""
url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
# Open the web browser in a new thread for command-line browser support
threading.Timer(1, webbrowser.open, args=(url,)).start()
cherrypy.quickstart(self)
def run_server(top10k, top100k, nlp, model):
cherrypy.config.update({
"environment": "production",
"log.screen": True
})
cherrypy.server.socket_port = 16384
#cherrypy.server.socket_host = "0.0.0.0"
rest_conf = {"/": {
"request.dispatch": cherrypy.dispatch.MethodDispatcher(),
'cors.expose.on': True
}}
cherrypy_cors.install()
cherrypy.quickstart(SimplifyEndpoint(top10k, top100k, nlp, model), "/simplify", rest_conf)
def run_cherrypy(port, root_kls=Root):
import logging
logging.getLogger("cherrypy").setLevel(logging.DEBUG)
cherrypy.config.update({
"server.socket_port": port,
"engine.autoreload.on": False,
"engine.timeout_monitor.on": False,
# "log.screen": False
})
cherrypy.quickstart(root_kls(), "/")
def run_app(listen_address="0.0.0.0:8001"):
host, port = listen_address.rsplit(':', 1)
cherrypy.config.update({
'server.socket_port': int(port),
'server.socket_host': host,
'tools.sessions.on': True,
'tools.sessions.storage_type': 'ram',
'tools.db.on': True,
'tools.authenticate.on': True,
'SOCIAL_AUTH_USER_MODEL': 'example.db.user.User',
'SOCIAL_AUTH_LOGIN_URL': '/',
'SOCIAL_AUTH_LOGIN_REDIRECT_URL': '/done',
})
cherrypy.config.update(SOCIAL_SETTINGS)
cherrypy.tools.jinja2env = Environment(
loader=FileSystemLoader(os.path.join(BASE_DIR, 'common', 'templates'))
)
cherrypy.tools.jinja2env.filters.update({
'backend_name': filters.backend_name,
'backend_class': filters.backend_class,
'icon_name': filters.icon_name,
'social_backends': filters.social_backends,
'legacy_backends': filters.legacy_backends,
'oauth_backends': filters.oauth_backends,
'filter_backends': filters.filter_backends,
'slice_by': filters.slice_by
})
cherrypy.tools.jinja2env.globals.update({
'url': url_for
})
cherrypy.tools.db = SATool()
cherrypy.tools.authenticate = cherrypy.Tool('before_handler', load_user)
cherrypy.tools.session = cherrypy.Tool('on_end_resource', session_commit)
cherrypy.quickstart(PSAExample())
def serve(path=None, port=8080):
if profile is None or pstats is None:
msg = ("Your installation of Python does not have a profile module. "
"If you're on Debian, try "
"`sudo apt-get install python-profiler`. "
"See http://www.cherrypy.org/wiki/ProfilingOnDebian "
"for details.")
warnings.warn(msg)
import cherrypy
cherrypy.config.update({'server.socket_port': int(port),
'server.thread_pool': 10,
'environment': "production",
})
cherrypy.quickstart(Profiler(path))
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()
import cherrypy
cherrypy.config.update({'server.socket_port': int(port),
'server.thread_pool': 10,
'environment': "production",
})
cherrypy.quickstart(CoverStats(cov, root))
def run(cls):
cherrypy_cors.install()
config = {
'/': {
'cors.expose.on': True,
},
}
cherrypy.quickstart(cls(), config=config)
def browser_authorize(self):
"""
Open a browser to the authorization url and spool up a CherryPy
server to accept the response
"""
url, _ = self.oauth.authorize_token_url(redirect_uri=self.redirect_uri)
# Open the web browser in a new thread for command-line browser support
threading.Timer(1, webbrowser.open, args=(url,)).start()
cherrypy.quickstart(self)
def startWebServer():
host = "discover" if not( settings.exists( "web" ) ) else settings.get( "web" )[ "host" ]
#cherrypy.server.socket_host = host if host != "discover" else get_ip_address() # use machine IP address if host = "discover"
cherrypy.server.socket_port = 80 if not( settings.exists( "web" ) ) else settings.get( "web" )[ "port" ]
log( LOG_LEVEL_STATE, CHILD_DEVICE_WEBSERVER, MSG_SUBTYPE_TEXT, "Starting on " + cherrypy.server.socket_host + ":" + str( cherrypy.server.socket_port ) )
conf = {
'/': {
'tools.staticdir.root': os.path.abspath( os.getcwd() ),
'tools.staticfile.root': os.path.abspath( os.getcwd() )
},
'/css': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/css'
},
'/javascript': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/javascript'
},
'/images': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/images'
},
'/schedule.json': {
'tools.staticfile.on': True,
'tools.staticfile.filename': './thermostat_schedule.json'
},
'/favicon.ico': {
'tools.staticfile.on': True,
'tools.staticfile.filename': './web/images/favicon.ico'
},
'/graph': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/graph'
}
}
cherrypy.config.update(
{ 'log.screen': debug,
'log.access_file': "",
'log.error_file': "",
'server.thread_pool' : 10
}
)
cherrypy.quickstart ( WebInterface(), '/', conf )
##############################################################################
# #
# Main #
# #
##############################################################################
def startWebServer():
host = "discover" if not( settings.exists( "web" ) ) else settings.get( "web" )[ "host" ]
cherrypy.server.socket_host = host if host != "discover" else get_ip_address() # use machine IP address if host = "discover"
cherrypy.server.socket_port = 80 if not( settings.exists( "web" ) ) else settings.get( "web" )[ "port" ]
log( LOG_LEVEL_STATE, CHILD_DEVICE_WEBSERVER, MSG_SUBTYPE_TEXT, "Starting on " + cherrypy.server.socket_host + ":" + str( cherrypy.server.socket_port ) )
conf = {
'/': {
'tools.staticdir.root': os.path.abspath( os.getcwd() ),
'tools.staticfile.root': os.path.abspath( os.getcwd() )
},
'/css': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/css'
},
'/javascript': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/javascript'
},
'/images': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './web/images'
},
'/schedule.json': {
'tools.staticfile.on': True,
'tools.staticfile.filename': './thermostat_schedule.json'
},
'/favicon.ico': {
'tools.staticfile.on': True,
'tools.staticfile.filename': './web/images/favicon.ico'
}
}
cherrypy.config.update(
{ 'log.screen': debug,
'log.access_file': "",
'log.error_file': ""
}
)
cherrypy.quickstart ( WebInterface(), '/', conf )
##############################################################################
# #
# Main #
# #
##############################################################################