本文整理匯總了Python中cherrypy.quickstart方法的典型用法代碼示例。如果您正苦於以下問題:Python cherrypy.quickstart方法的具體用法?Python cherrypy.quickstart怎麽用?Python cherrypy.quickstart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cherrypy
的用法示例。
在下文中一共展示了cherrypy.quickstart方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def init(database_filename, host, port):
"""
Configure and starts the server.
:param database_filename: Location of the database file.
:param host: Address on which to listen.
:param port: Port on which to listen.
"""
cherrypy_cors.install()
config = {
'/': {
'cors.expose.on': True,
'tools.sessions.on': True,
'tools.response_headers.on': True,
'tools.response_headers.headers': [('Content-Type', 'text/plain')],
},
}
cherrypy.config.update({
'server.socket_host': host,
'server.socket_port': port,
})
cherrypy.quickstart(Server(database_filename), "/api", config=config)
示例2: serve
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
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))
示例3: serve
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
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))
示例4: browser_authorize
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
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)
示例5: run
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def run():
_c = sqlite3.connect(dbname)
try:
db.set_admins(_c, app_config["admins"])
# user anonymity is achieved in the laziest possible way: a literal user
# named anonymous. may god have mercy on my soul.
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)
示例6: run
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def run(self):
conf = { '/': {}}
cherrypy.quickstart(self.__root, '/', conf)
示例7: main
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def main():
"""Main."""
conf = {
"/": {
'request.dispatch': cherrypy.dispatch.MethodDispatcher()
}
}
cherrypy.quickstart(TuxyCaptcha(), "/", conf)
示例8: main
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def main():
"""Main."""
conf = {
"/": {
'tools.sessions.on': True,
}
}
cherrypy.quickstart(TuxyBot(), "/", conf)
示例9: coudeploy
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def coudeploy():
serverconf = os.path.join(os.path.dirname(__file__), 'server.conf')
def error_404(status, message, traceback, version):
return '''{"error":"not_found","reason":"no_db_file"}'''
error_404.exposed = True
cherrypy.config.update({'error_page.404':error_404})
access_log = cherrypy.log.access_log
cherrypy.quickstart(Couchpot(), config=serverconf)
示例10: main
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def main() :
"""
cherrypy.root = QuillCherry()
cherrypy.root.quillpad_backend = cherrypy.root
cherrypy.config.update( file='quill_cherry8088.conf')
cherrypy.config.update({'thread_pool': 10})
cherrypy.server.start()
"""
cherrypy._cpconfig.Config('quill_cherry8088.conf')
quillCherry = QuillCherry()
cherrypy.quickstart(quillCherry)
示例11: main
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def main():
# Start web server
cherrypy.config.update({"server.socket_host": "0.0.0.0", "server.socket_port": 80})
cherrypy.quickstart(Root(), "/")
示例12: web_main_thread
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def web_main_thread(sensors_data_storage):
cherrypy.config.update({'environment': 'embedded',
'server.socket_port': 8089,
'engine.autoreload_on': False})
th = threading.Thread(None, backfill_thread, "backfill_thread",
(sensors_data_storage,))
th.daemon = True
th.start()
cherrypy.quickstart(WebWally(sensors_data_storage), '/')
示例13: run
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
def run( self, args ):
api = RuntimeWebAPI()
global_config = {
"server.socket_host": args.host,
"server.socket_port": int(args.port)
}
my_config = {"/": {}}
cherrypy.config.update(global_config)
cherrypy.quickstart(api, "/", config=my_config)
示例14: serve
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
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))
示例15: serve
# 需要導入模塊: import cherrypy [as 別名]
# 或者: from cherrypy import quickstart [as 別名]
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))