本文整理汇总了Python中tornado.web.Application类的典型用法代码示例。如果您正苦于以下问题:Python Application类的具体用法?Python Application怎么用?Python Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(urls_map):
settings = {"auto_reload": True, "debug": True}
application = Application(urls_map, **settings)
application.listen(9999)
logging.info("API server is running on port 9999")
ioloop_instance = tornado.ioloop.IOLoop.instance()
ioloop_instance.start()
开发者ID:Vito2015,项目名称:rima,代码行数:7,代码来源:server.py
示例2: __init__
def __init__(self):
# handlers = [
# (r'/', IndexHandler),
#
# # 所有html静态文件都默认被StaticFileHandler处理
# # (r'/tpl/(.*)', StaticFileHandler, {
# # 'path': os.path.join(os.path.dirname(__file__), 'templates')
# # }),
# # PC端网页
# # (r'/f/', RedirectHandler, {'url': '/f/index.html'}),
# # (r'/f/(.*)', StaticFileHandler, {
# # 'path': os.path.join(os.path.dirname(__file__), 'front')
# # }),
# ]
handlers = []
handlers.extend(nui.routes)
handlers.extend(service.routes)
handlers.extend(stock.routes)
handlers.extend(smscenter.routes)
handlers.extend(weui.routes)
handlers.extend(routes)
site_url_prefix = settings.get(constant.SITE_URL_PREFIX, "")
if site_url_prefix:
# 构建新的URL
handlers = map(
lambda x: url(site_url_prefix + x.regex.pattern, x.handler_class, x.kwargs, x.name), handlers
)
# handlers = get_handlers()
# 配置默认的错误处理类
settings.update({"default_handler_class": ErrorHandler, "default_handler_args": dict(status_code=404)})
Application.__init__(self, handlers=handlers, **settings)
开发者ID:hulingfeng211,项目名称:mywork,代码行数:34,代码来源:manage.py
示例3: __init__
def __init__(self):
settings = {}
settings["debug"] = True
handlers = []
handlers.extend(UploadWebService.get_handlers())
self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
Application.__init__(self, handlers, **settings)
开发者ID:Bossuo,项目名称:ppmessage,代码行数:7,代码来源:tornadouploadapp.py
示例4: main
def main():
global http_server
try:
signal(SIGTERM, on_signal)
parse_command_line()
if options.config != None:
parse_config_file(options.config)
path = join(dirname(__file__), "templates")
application = Application(
[(r"/", IndexHandler), (r"/stock", StockHandler)],
template_path=path,
static_path=join(dirname(__file__), "static"),
)
application.db = motor.MotorClient(options.db_host, options.db_port).open_sync()[options.db_name]
http_server = HTTPServer(application)
http_server.listen(options.port, options.address)
log().info("server listening on port %s:%d" % (options.address, options.port))
if log().isEnabledFor(DEBUG):
log().debug("autoreload enabled")
tornado.autoreload.start()
IOLoop.instance().start()
except KeyboardInterrupt:
log().info("exiting...")
except BaseException as ex:
log().error("exiting due: [%s][%s]" % (str(ex), str(format_exc().splitlines())))
exit(1)
开发者ID:irr,项目名称:stock-labs,代码行数:34,代码来源:Server.py
示例5: main
def main():
root_dir = os.path.abspath(os.path.split(__file__)[0])
print(root_dir)
app = Application([(r'/gfxtablet', GfxTabletHandler),
#(r'/(index.js|src/.*\.js|node_modules/.*\.js)', StaticFileHandler, {}),
(r'/', MainHandler)],
debug=config.get('DEBUG', False), static_path=root_dir, static_url_prefix='/static/')
_logger.info("app.settings:\n%s" % '\n'.join(['%s: %s' % (k, str(v))
for k, v in sorted(app.settings.items(),
key=itemgetter(0))]))
port = config.get('PORT', 5000)
app.listen(port)
_logger.info("listening on port %d" % port)
_logger.info("press CTRL-C to terminate the server")
_logger.info("""
-----------
G f x T a b l e t
*************************
*********************************
STARTING TORNADO APP!!!!!!!!!!!!!
*********************************
*************************
G f x T a b l e t
-----------
""")
IOLoop.instance().start()
开发者ID:jzitelli,项目名称:GfxTablet.js,代码行数:29,代码来源:tornado_server.py
示例6: run_auth_server
def run_auth_server():
client_store = ClientStore()
client_store.add_client(client_id="abc", client_secret="xyz",
redirect_uris=[],
authorized_grants=[oauth2.grant.ClientCredentialsGrant.grant_type])
token_store = TokenStore()
# Generator of tokens
token_generator = oauth2.tokengenerator.Uuid4()
token_generator.expires_in[oauth2.grant.ClientCredentialsGrant.grant_type] = 3600
provider = Provider(access_token_store=token_store,
auth_code_store=token_store, client_store=client_store,
token_generator=token_generator)
# provider.add_grant(AuthorizationCodeGrant(site_adapter=TestSiteAdapter()))
provider.add_grant(ClientCredentialsGrant())
try:
app = Application([
url(provider.authorize_path, OAuth2Handler, dict(provider=provider)),
url(provider.token_path, OAuth2Handler, dict(provider=provider)),
])
app.listen(8080)
print("Starting OAuth2 server on http://localhost:8080/...")
IOLoop.current().start()
except KeyboardInterrupt:
IOLoop.close()
开发者ID:niyoufa,项目名称:pyda,代码行数:30,代码来源:oauthlib.py
示例7: main
def main():
application = Application([
(r"/", MainHandler),
(r"/login", LoginHandler),
(r"/logout", LogoutHandler),
(r"/events", EventHandler),
(r"/translations/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)", TranslationHandler),
(r"/translations/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)/button", ButtonHandler),
(r"/selections/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)/([A-Za-z0-9_]+)", SelectionHandler),
(r"/flags/([A-Za-z0-9_]+)", ImageHandler, {
'location': os.path.join(os.path.dirname(__file__), 'flags', '%s'),
'fallback': os.path.join(os.path.dirname(__file__), 'static', 'flag.png')
}),
], **{
"login_url": "/",
"template_path": os.path.join(os.path.dirname(__file__), "templates"),
"static_path": os.path.join(os.path.dirname(__file__), "static"),
"cookie_secret": base64.b64encode("000000000000000000000"),
})
application.listen(8891)
try:
IOLoop.instance().start()
except KeyboardInterrupt:
# Exit cleanly.
return
开发者ID:cms-dev,项目名称:tws,代码行数:26,代码来源:TranslationWebServer.py
示例8: test_proxy
def test_proxy(self):
config = {
"endpoints": {"https://app.datadoghq.com": ["foo"]},
"proxy_settings": {
"host": "localhost",
"port": PROXY_PORT,
"user": None,
"password": None
}
}
app = Application()
app.skip_ssl_validation = True
app._agentConfig = config
trManager = TransactionManager(MAX_WAIT_FOR_REPLAY, MAX_QUEUE_SIZE, THROTTLING_DELAY)
trManager._flush_without_ioloop = True # Use blocking API to emulate tornado ioloop
CustomAgentTransaction.set_tr_manager(trManager)
app.use_simple_http_client = False # We need proxy capabilities
app.agent_dns_caching = False
# _test is the instance of this class. It is needed to call the method stop() and deal with the asynchronous
# calls as described here : http://www.tornadoweb.org/en/stable/testing.html
CustomAgentTransaction._test = self
CustomAgentTransaction.set_application(app)
CustomAgentTransaction.set_endpoints(config['endpoints'])
CustomAgentTransaction('body', {}, "") # Create and flush the transaction
self.wait()
del CustomAgentTransaction._test
access_log = self.docker_client.exec_start(
self.docker_client.exec_create(CONTAINER_NAME, 'cat /var/log/squid/access.log')['Id'])
self.assertTrue("CONNECT" in access_log) # There should be an entry in the proxy access log
self.assertEquals(len(trManager._endpoints_errors), 1) # There should be an error since we gave a bogus api_key
开发者ID:alq666,项目名称:dd-agent,代码行数:33,代码来源:test_proxy.py
示例9: __init__
def __init__(self):
settings = {
"static_path": os.path.join(os.path.dirname(__file__), "static"),
"cookie_secret": COOKIE_KEY,
"login_url": "/login",
}
Application.__init__(self, routes, debug=DEBUG, **settings)
开发者ID:rakoo,项目名称:newebe,代码行数:7,代码来源:newebe_server.py
示例10: main
def main():
parse_command_line()
flagfile = os.path.join(os.path.dirname(__file__), options.flagfile)
parse_config_file(flagfile)
settings = dict(
login_url='/todo/login',
debug=True,
template_path=os.path.join(os.path.dirname(__file__), 'templates'),
static_path=os.path.join(os.path.dirname(__file__), 'static'),
cookie_secret=options.cookie_secret,
dropbox_consumer_key=options.dropbox_consumer_key,
dropbox_consumer_secret=options.dropbox_consumer_secret,
)
#print options.dropbox_consumer_key
#print options.dropbox_consumer_secret
app = Application([
('/', RootHandler),
('/todo/?', TodoHandler),
('/todo/add', AddHandler),
('/delete', DeleteHandler),
('/create', CreateHandler),
('/todo/login', DropboxLoginHandler),
('/todo/logout', LogoutHandler),
], **settings)
app.listen(options.port,address='127.0.0.1',xheaders=True)
IOLoop.instance().start()
开发者ID:wynemo,项目名称:simpletodo,代码行数:28,代码来源:main.py
示例11: __init__
def __init__(self):
handlers = [
(r"/", IndexHandler),
(r"/schedule", ScheduleHandler),
(r"/recently", RecentlyViewHandler),
(r"/overview", OverViewHandler),
(r"/domains", DomainsViewHandler),
(r"/details", DomainDetailHandler),
]
config = dict(
template_path=os.path.join(os.path.dirname(__file__), settings.TEMPLATE_ROOT),
static_path=os.path.join(os.path.dirname(__file__), settings.STATIC_ROOT),
#xsrf_cookies=True,
cookie_secret="__TODO:_E720135A1F2957AFD8EC0E7B51275EA7__",
autoescape=None,
debug=settings.DEBUG
)
Application.__init__(self, handlers, **config)
self.rd_main = redis.Redis(settings.REDIS_HOST,
settings.REDIS_PORT,
db=settings.REDIS_DB)
self.db = Connection(
host=settings.MYSQL_HOST, database=settings.MYSQL_DB,
user=settings.MYSQL_USER, password=settings.MYSQL_PASS)
开发者ID:yidun55,项目名称:crawler,代码行数:25,代码来源:app.py
示例12: __init__
def __init__(self):
settings = load_settings(config)
handlers = [
(r'/$', StaticHandler, dict(
template_name='index.html',
title=settings['site_title']
)),
(r'/drag', StaticHandler, dict(
template_name='draggable.html',
title=settings['site_title']
)),
(r'/http', StaticHandler, dict(
template_name='httpdemo.html',
title=settings['site_title']
)),
(r'/demo', HTTPDemoHandler),
(r'/demo/quickstart',StaticHandler,dict(
template_name='App/demo/quickstart.html'
)),
(r'/user/list', UserHandler),
(r'/user', UserHandler),#post
(r'/user/(\w+)', UserHandler),#delete
]
self.db = settings['db']
self.dbsync = settings['dbsync']
Application.__init__(self, handlers, **settings)
开发者ID:hulingfeng211,项目名称:angularjs,代码行数:28,代码来源:manage.py
示例13: run
def run(self):
loop = IOLoop()
app = Application([
(r'/', WsSocketHandler)
])
app.listen(self.port)
loop.start()
开发者ID:poppy-project,项目名称:pypot,代码行数:7,代码来源:ws.py
示例14: main
def main():
app = Application([
(r'/', MainHandler),
(r'/res', ResourceHandler)
], debug=True, gzip=True, cookie_secret='nice to meet you', template_path='templates', static_path='public', static_url_prefix="/public/");
app.listen(8000)
IOLoop.instance().start()
开发者ID:aaronzhang1990,项目名称:workshare,代码行数:7,代码来源:app.py
示例15: make_server
def make_server(config_path):
root = path.dirname(__file__)
static_path = path.join(root, 'static')
template_path = path.join(root, 'template')
define('port', default=7777, type=int)
define('production', default=False, type=bool)
define('mongo_db_name', default='open_wireless_map', type=str)
define('mongo_host', default='localhost', type=str)
define('mongo_port', default=27017, type=int)
define('mongo_user', default=None, type=str)
define('mongo_password', default=None, type=str)
define('api_password_hash', default=None, type=str)
parse_config_file(config_path)
app_config = dict(static_path=static_path,
template_path=template_path)
if not options.production:
app_config.update(debug=True)
server = Application(url_map, **app_config)
server.settings['api_password_hash'] = options.api_password_hash
server.settings['mongo'] = get_mongo(db_name=options.mongo_db_name,
host=options.mongo_host,
port=options.mongo_port,
user=options.mongo_user,
password=options.mongo_password)
return server
开发者ID:charlesthomas,项目名称:open_wireless_map,代码行数:29,代码来源:server.py
示例16: run
def run():
parser = ArgumentParser()
parser.add_argument("-f", "--fake", action="store_true", help="Use a fake connection for development")
parser.add_argument("-i", "--id", default=socket.gethostname(), help="ID of this site")
args = parser.parse_args()
if args.fake:
m = MissileLauncher(FakeMissileLauncherConnection())
else:
m = MissileLauncher(MissileLauncherConnection(0))
config = {
'launcher': m,
'id': args.id
}
application = Application([
(r"/position", PositionHandler, config),
(r"/move/(-?[01])/(-?[01])", PositionHandler, config),
(r"/move_to/([-0-9.]*)/([-0-9.]*)", MoveHandler, config),
(r"/fire_at/([-0-9.]*)/([-0-9.]*)", FireHandler, config),
(r"/calibrate", CalibrateHandler, config),
(r"/", IndexHandler),
(r"/static/(.*)", StaticFileHandler, {'path': 'static/'})
], debug=True)
application.listen(7777)
periodic = PeriodicCallback(m.timestep, 100)
periodic.start()
print('Site {} listening at http://{}:7777'.format(args.id, socket.gethostname()))
IOLoop.instance().start()
开发者ID:JohannesEbke,项目名称:rapidfeedback,代码行数:31,代码来源:missilesite.py
示例17: __init__
def __init__(self):
logging.getLogger().setLevel(options.logging_level)
if options.debug:
logging.warn("==================================================================================")
logging.warn("SERVER IS RUNNING IN DEBUG MODE! MAKE SURE THIS IS OFF WHEN RUNNING IN PRODUCTION!")
logging.warn("==================================================================================")
logging.info("Starting server...")
# apollo distribution root
dist_root = os.path.join(os.path.dirname(__file__), "..", "..")
Application.__init__(
self,
[
(r"/", FrontendHandler),
(r"/session", SessionHandler),
(r"/action", ActionHandler),
(r"/events", EventsHandler),
(r"/dylib/(.*)\.js", DylibHandler)
],
dist_root = dist_root,
static_path = os.path.join(dist_root, "static"),
debug = options.debug
)
self.loader = Loader(os.path.join(dist_root, "template"))
setupDBSession()
self.dylib_dispatcher = DylibDispatcher(self)
self.bus = Bus(self)
self.plugins = PluginRegistry(self)
self.cron = CronScheduler(self)
开发者ID:thecowboy,项目名称:apollo,代码行数:35,代码来源:core.py
示例18: run
def run():
parser = ArgumentParser()
parser.add_argument("-t", "--targets", help="File with 'targetid x y' tuples in range of this rocket launcher")
parser.add_argument("-s", "--sites", help="File with site_id and URL")
args = parser.parse_args()
sites = {}
if args.sites:
for site_line in open(args.sites).readlines():
site_id, url = site_line.split()
sites[site_id] = url
targets = {}
if args.targets:
for person_line in open(args.targets).readlines():
name, site, x, y = person_line.split()
targets[name] = sites[site], map(float, (x, y))
config = {
'targets': targets
}
application = Application([
(r"/fire_at/([^/]*)", TargetHandler, config)
], debug=True)
application.listen(6666)
print('Listening at http://localhost:6666')
IOLoop.instance().start()
开发者ID:anotherthomas,项目名称:rapidfeedback,代码行数:29,代码来源:missilecontrol.py
示例19: run_auth_server
def run_auth_server():
client_store = ClientStore()
client_store.add_client(client_id="abc", client_secret="xyz", redirect_uris=["http://localhost:8081/callback"])
token_store = TokenStore()
provider = Provider(
access_token_store=token_store, auth_code_store=token_store, client_store=client_store, token_generator=Uuid4()
)
provider.add_grant(AuthorizationCodeGrant(site_adapter=TestSiteAdapter()))
try:
app = Application(
[
url(provider.authorize_path, OAuth2Handler, dict(provider=provider)),
url(provider.token_path, OAuth2Handler, dict(provider=provider)),
]
)
app.listen(8080)
print("Starting OAuth2 server on http://localhost:8080/...")
IOLoop.current().start()
except KeyboardInterrupt:
IOLoop.close()
开发者ID:rcmlee99,项目名称:python-oauth2,代码行数:25,代码来源:tornado_server.py
示例20: main
def main():
define("host", default="127.0.0.1", help="Host IP")
define("port", default=8080, help="Port")
define("mongodb_url", default="127.0.0.1:27017", help="MongoDB connection URL")
tornado.options.parse_command_line()
client = motor.motor_tornado.MotorClient(options.mongodb_url)
db = client['imgr']
template_dir = os.getenv('OPENSHIFT_REPO_DIR', '')
template_dir = os.path.join(template_dir, 'imgr/templates')
static_dir = os.getenv('OPENSHIFT_DATA_DIR', os.path.dirname(__file__))
static_dir = os.path.join(static_dir, 'static')
settings = {
"static_path": static_dir,
'template_path': template_dir
}
application = Application([(r"/files/([^/]+)/?", MainHandler, dict(db=db)),
(r"/files/?", MainHandler, dict(db=db)),
(r'/?', HomeHandler, ),
(r'/([^/]+)/?', FileHandler, )],
**settings)
application.listen(options.port, options.host)
tornado.ioloop.IOLoop.instance().start()
开发者ID:helderm,项目名称:imgr,代码行数:27,代码来源:webapp.py
注:本文中的tornado.web.Application类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论