当前位置: 首页>>代码示例>>Python>>正文


Python web.url函数代码示例

本文整理汇总了Python中tornado.web.url函数的典型用法代码示例。如果您正苦于以下问题:Python url函数的具体用法?Python url怎么用?Python url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
  parse_command_line()
  client = AsyncHTTPClient(max_clients = 100)
  template_path = os.path.join(os.path.dirname(__file__), 'templates')
  static_path = os.path.join(os.path.dirname(__file__), 'static')
  template_loader_factory = lambda: template.Loader(template_path)

  handlers = [
    url(r'/$', RootHandler),
    url(r'/logout$', LogoutHandler),
    url(r'/submityelp$', SubmitYelpHandler),
    url(r'/matchvenues$', MatchVenuesHandler),
    url(r'%s$' % OAuthLoginHandler.URI, OAuthLoginHandler)
  ]

  app = Application(
    handlers,
    debug = options.debug,
    xsrf_cookies = False, # TODO
    cookie_secret = 'deadb33fd00dc9234adeda42777',
    template_path = template_path,
    static_path = static_path,
    memcache_client = memcache.Client([options.memcache_host], debug = 0),
    httpclient = client
  )

  logging.info('starting on port %d' % options.port)
  server = tornado.httpserver.HTTPServer(app)
  server.listen(options.port)
  tornado.ioloop.IOLoop.instance().start()
开发者ID:dolapo,项目名称:chupayelpa,代码行数:30,代码来源:main.py

示例2: 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

示例3: main

def main():
    app = web.Application([
        web.url(r'/sub', SubscribeSocket),
        web.url(r'/pub', PublishHandler)
    ])

    try:
        app.listen(8085)
    except OSError as e:
        print(str.format(
            '[%] {}', e
        ))
        sys.exit(1)

    ioloop.IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop')
    loop = ioloop.IOLoop.current()

    try:
        print('[*] Starting tornado application on [localhost: 8085]...')
        loop.start()
    except Exception as e:
        print(str.format(
            '[%] {}', e
        ))

        loop.stop()
开发者ID:arheo,项目名称:python_core,代码行数:26,代码来源:app3.py

示例4: runserver

def runserver(args):
    # set up logging to std out as default
    logging.getLogger().setLevel(logging.DEBUG)
    tornado.options.enable_pretty_logging()

    # set up the Django app, TODO: move to webui module
    wsgi_app = tornado.wsgi.WSGIContainer(django.core.handlers.wsgi.WSGIHandler())

    # this guy tracks all the Remote Players
    player_state = dict(state=ps.PlayerState())

    application = tornado.web.Application([
        (r'/api/1/content/(\d+)/data',          StreamingContentHandler),
        (r'/api/1/playback/players',            ps.RemotePlayerListHandler , player_state),
        url(r'/api/1/playback/players/(\d+)',   ps.RemotePlayerHandler, player_state, 'player'),
        (r'/api/1/playback/players/register',   ps.RemotePlayerSocket, player_state),
        (r'/api/1/playback/sessions',           ps.SessionListHandler, player_state),
        url(r'/api/1/playback/sessions/(\d+)',  ps.SessionHandler, player_state, 'session'),
        (r'.*', FallbackHandler, dict(fallback=wsgi_app))
        ], static_path=resource_filename('krum.webui', 'static'), # TODO: move to webui module
        debug=True
    )
    server = HTTPServer(application)
    server.bind(args.port)
    server.start(1)
    tornado.ioloop.IOLoop.instance().start()
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:26,代码来源:webserver.py

示例5: make_app

def make_app():
    return Application([
            url(r'/ptz/help', HelpHandler),
            url(r"/ptz/config(/?)", GetConfigHandler),
            url(r'/ptz/([^\/]+)/([^\/]+)/([^\?]+)', ControllingHandler),
            url(r'/ptz/internal', InternalHandler),
            ])
开发者ID:jetlive,项目名称:zkonvif,代码行数:7,代码来源:PtzServer.py

示例6: __init__

    def __init__(self):
        settings = setting_from_object(config)
        
        handlers = [
            url(r"/static/download/(.*)", tornado.web.StaticFileHandler, dict(path=settings['upload_path']), name='upload_path'),       
            url(r"/static/js/(.+)", tornado.web.StaticFileHandler, dict(path=settings['js_path']), name='js_path'),
            url(r"/static/css/(.+)", tornado.web.StaticFileHandler, dict(path=settings['css_path']), name='css_path'),
            url(r"/static/img/(.+)", tornado.web.StaticFileHandler, dict(path=settings['img_path']), name='img_path'),
            url(r"/static/fonts/(.+)", tornado.web.StaticFileHandler, dict(path=settings['fonts_path']), name='fonts_path'),
       
        ]
        handlers += Route.routes()
        handlers.append((r"/(.*)", ErrorHandler))  # Custom 404 ErrorHandler

        # static_path 的设置和StaticFileHandler,以及static_url函数有关
        # settings['static_path'] = settings['project_path']
        settings.update(dict(
            gzip = True,
            ui_modules = uimodules,
            autoescape = None
        ))
        
        if 'default_locale' in settings:
            tornado.locale.load_gettext_translations(
                os.path.join(os.path.dirname(__file__), 'translations'), 'messages')

        tornado.web.Application.__init__(self, handlers, **settings)
        
        self.forms = create_forms()
        pool = redis.ConnectionPool(host=settings['redis_host'], port=settings['redis_port'], db=settings['redis_db'])
        self.redis = redis.Redis(connection_pool=pool)
        self.session_store = RedisSessionStore(self.redis)
        
        configure_signals(db.sender)
开发者ID:ccfr32,项目名称:www,代码行数:34,代码来源:__init__.py

示例7: __init__

    def __init__(self):
        dialog_service = Dialog(
            username=WATSON_USERNAME,
            password=WATSON_PASSWORD
        )
        dialog_id = WATSON_DIALOG_ID

        # # CREATE A DIALOG
        # with open(join(dirname(__file__), '../dialog_files/jemboo-dialog-file.xml')) as dialog_file:
        #     create_dialog_response = dialog_service.update_content(dialog_file=dialog_file, name='jemboo-dialog')

        # UPDATE A DIALOG
        # with open(join(dirname(__file__), '../dialog_files/jemboo-dialog-file.xml')) as dialog_file:
        #
        #     create_dialog_response = dialog_service.update_dialog(dialog_file=dialog_file, dialog_id=dialog_id)


        handlers = [
            url(r"/api/bluemix/initChat", InitChat, dict(dialog_service=dialog_service, dialog_id=dialog_id),
                name="root"),
            url(r"/api/bluemix/postConversation", Conversation,
                dict(dialog_service=dialog_service, dialog_id=dialog_id), name="conversation"),
            (r'/()', tornado.web.StaticFileHandler, {'path': "static/index.html"}),
            (r'/(.*)', tornado.web.StaticFileHandler, {'path': "static/"}),
            # (r'/static/(.*)', tornado.web.StaticFileHandler, {'path': static_path}),

        ]

        settings = dict(
            template_path=join(dirname(__file__), "../templates"),
            # static_path=os.path.join(os.path.dirname(__file__), "../static"),
            debug=tornado.options.options.debug,
        )
        tornado.web.Application.__init__(self, handlers, **settings)
开发者ID:rdefeo,项目名称:dialog,代码行数:34,代码来源:application.py

示例8: get_app

    def get_app(self):
        self.packages = spy(mappers.PackageMapper(empty_stub()))
        self.cache = spy(cache.Cache(self.packages, None, None))
        self.pypi_fallback = "http://pypi.python.org/simple/%s/"

        return web.Application([
                web.url(r'/distutils/',
                    handlers.DistutilsDownloadHandler, dict(packages=self.packages, cache=self.cache)
                ),
                web.url(r'/distutils/(?P<id_>%s)/' % viper.identifier(),
                    handlers.DistutilsDownloadHandler, dict(packages=self.packages, cache=self.cache),
                    name='distutils_package'
                ),
                web.url(r'/distutils/(?P<id_>%s)/(?P<version>%s)' % (viper.identifier(), viper.identifier()),
                    handlers.DistutilsDownloadHandler, dict(packages=self.packages, cache=self.cache),
                    name='distutils_package_with_version'
                ),
                web.url(r'/packages/(?P<id_>%s)' % viper.identifier(),
                    handlers.PackageHandler, dict(packages=self.packages, cache=self.cache),
                    name='package'
                ),
                web.url(r'/files/(?P<id_>%s)' % viper.identifier(),
                    handlers.FileHandler, dict(files=None),
                    name='file'
                )
            ],
            debug=True,
            template_path=os.path.join(os.path.dirname(handlers.__file__), 'templates'),
            static_path=os.path.join(os.path.dirname(handlers.__file__), 'static'),
            pypi_fallback=self.pypi_fallback
        )
开发者ID:jaimegildesagredo,项目名称:viper,代码行数:31,代码来源:test_distutils_download_handler.py

示例9: configure_app

def configure_app(self, config=None, log_level='INFO', debug=False, static_path=None):
    template_path = abspath(join(dirname(__file__), 'templates'))
    static_path = abspath(join(dirname(__file__), 'static'))

    self.config = config

    handlers = [
        url(r'/', HomeHandler, name="home"),
        url(r'/locations', LocationsHandler, name="location"),
    ]

    self.redis = redis.StrictRedis(
        host=self.config.REDIS_HOST,
        port=self.config.REDIS_PORT,
        db=self.config.REDIS_DB_COUNT,
        password=self.config.REDIS_PASSWORD
    )

    options = {
        "cookie_secret": self.config.COOKIE_SECRET,
        "template_path": template_path,
        "static_path": static_path,
        "static_url_prefix": self.config.STATIC_URL
    }

    if debug:
        options['debug'] = True

    return handlers, options
开发者ID:heynemann,项目名称:locationer,代码行数:29,代码来源:app.py

示例10: main

def main():
    pid_fname = "host.pid"
    p = open(pid_fname, 'w')
    try:
        log.portalocker.lock(p, log.portalocker.LOCK_EX | log.portalocker.LOCK_NB)
    except Exception as e:
        print e
        print 'ERR: only one instance can be started!!!'
        return

    app = Application([
            url(r'/host/util', HostUtilsHandler),
            url(r'/host/internal', InternalHandler),
            url(r'/host/help', HelpHandler),
            ])
    app.listen(10004)

    rh = RegHt([ { 'type':'host', 'id':'0', 'url':'http://<ip>:10004/host' } ])

    global _pm
    _pm = PerformanceMonitor()
    _pm.start()

    global _ioloop
    _ioloop = IOLoop.instance()
    _ioloop.start()
开发者ID:jetlive,项目名称:zkonvif,代码行数:26,代码来源:HostUtils.py

示例11: main

def main():
    arr_threads = []

    #TODO: rebuild RequestQueue from log, and set currentJobID


    #prepare Thread to Consume RequestQueue and Produce ProcessQueue
    for i in range(nr_jobSaver):
        arr_threads.append(JobSaver(i))

    #prepare Thread to Consume ProcessQueue
    for i in range(nr_jobConsumer):
        arr_threads.append(JobConsumer(i))

    #start threads
    for t in arr_threads:
        t.start()

    #start server for incoming jobs
    app = Application([
        url(r"/", JobHandler),
        url(r"/status", StatusHandler),
        url(r"/stop", StopServerHandler),
    ])
    app.listen(8888)
    ioloop.IOLoop.current().start()
开发者ID:felix021,项目名称:pyTaskQ,代码行数:26,代码来源:pyTaskQ.py

示例12: __init__

    def __init__(self):
        settings = dict(
            # static_path = os.path.join(os.path.dirname(__file__), "static"),
            # template_path = os.path.join(os.path.dirname(__file__), "templates"),
            debug=tornado.options.options.debug,
        )
        context_data = ContextData()
        context_data.open_connection()
        attribute_product_data = AttributeProductData()
        attribute_product_data.open_connection()

        contextualizer = Contextualizer(context_data, attribute_product_data)

        tornado.web.Application.__init__(
            self,
            [
                url(
                    r"/([0-9a-fA-F]+)?",
                    handlers.ContextHandler,
                    dict(contextualizer=contextualizer),
                    name="context"
                ),
                url(r"/([0-9a-fA-F]+)/messages", handlers.MessagesHandler, name="messages"),
                url(
                    r"/([0-9a-fA-F]+)/messages/",
                    handlers.MessageHandler,
                    dict(contextualizer=contextualizer),
                    name="message"
                ),
                url(r"/([0-9a-fA-F]+)/feedback/", handlers.FeedbackHandler, name="feedback"),
                url(r"/status", handlers.StatusHandler, name="status")
            ],
            **settings
        )
开发者ID:rdefeo,项目名称:context,代码行数:34,代码来源:application.py

示例13: make_app

def make_app(
    url_prefix="/qcache",
    debug=False,
    max_cache_size=1000000000,
    max_age=0,
    statistics_buffer_size=1000,
    basic_auth=None,
    default_filter_engine=FILTER_ENGINE_NUMEXPR,
):
    if basic_auth:
        global auth_user, auth_password
        auth_user, auth_password = basic_auth.split(":", 2)

    stats = Statistics(buffer_size=statistics_buffer_size)
    cache = DatasetCache(max_size=max_cache_size, max_age=max_age)
    return Application(
        [
            url(
                r"{url_prefix}/dataset/([A-Za-z0-9\-_]+)/?(q)?".format(url_prefix=url_prefix),
                DatasetHandler,
                dict(dataset_cache=cache, state=AppState(), stats=stats, default_filter_engine=default_filter_engine),
                name="dataset",
            ),
            url(r"{url_prefix}/status".format(url_prefix=url_prefix), StatusHandler, dict(), name="status"),
            url(
                r"{url_prefix}/statistics".format(url_prefix=url_prefix),
                StatisticsHandler,
                dict(dataset_cache=cache, stats=stats),
                name="statistics",
            ),
        ],
        debug=debug,
        transforms=[CompressedContentEncoding],
    )
开发者ID:tobgu,项目名称:qcache,代码行数:34,代码来源:app.py

示例14: start_http_server

def start_http_server(port):
    application = Application([
        url(r'/health', HealthHandler),
        url(r'/metrics', MetricsHandler),
        url(r'/connectors', ConnectorsHandler)
    ])
    HTTPServer(application).listen(port)
开发者ID:zalando,项目名称:nakadi-end2end,代码行数:7,代码来源:server.py

示例15: make_app

def make_app():

    return Application([
        url(r"/login", Login),
        url(r"/logout", Logout),
        url(r"/.*", HelloHandler)],
        cookie_secret="4") # Choosen by a fair dice roll
开发者ID:jbzdak,项目名称:laughing-cyril,代码行数:7,代码来源:server.py


注:本文中的tornado.web.url函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。