• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python web.url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __init__

    def __init__(self):
        # self.config = self._get_config()
        handlers = [
            url(r"/", IndexHandler, name="index"),
            url(r"/hello", HelloWorldHandler, name="hello"),
            url(r"/single", SingleFieldHandler, name="single"),
            url(r"/price", PriceHandler, name="price"),
            url(r"/postcode", PostcodeHandler, name="postcode"),
        ]

        # xsrf_cookies is for XSS protection add this to all forms: {{ xsrf_form_html() }}
        settings = {
            "static_path": os.path.join(os.path.dirname(__file__), "static"),
            "template_path": os.path.join(os.path.dirname(__file__), "templates"),
            "cookie_secret": base64.b64encode(uuid.uuid4().bytes + uuid.uuid4().bytes),
            #'xsrf_cookies': True,
            "debug": False,
            "log_file_prefix": "tornado.log",
        }

        tornado.web.Application.__init__(self, handlers, **settings)  # debug=True ,
        # Connect to mongodb
        self.connection = pymongo.Connection(MONGO_SERVER, 27017, max_pool_size=1000)
        self.db = self.connection["houseprices"]

        # we preload dates & postcode_parts
        self.legal_dates = self.db.houses.distinct("dateadded")

        legal_postcodes_results = self.db.houses.distinct("postcode_part")

        self.legal_postcodes = []
        for p in legal_postcodes_results:
            self.legal_postcodes.append(p)
        self.legal_postcodes.sort()
开发者ID:bootandy,项目名称:python-frameworks,代码行数:34,代码来源:app.py


示例17: main

def main():  # pragma: no cover
    """
    Actually fire up the web server.

    Listens on 4096.
    """
    define('port', default=4096)
    define('style_host', default='localhost')
    define('style_port', default=4097)
    define('log_level', default='INFO')
    define('log_format', default='%(asctime)s %(levelname)s [%(thread)d] ' +
           '[%(X-Socrata-RequestId)s] %(name)s %(message)s')
    parse_command_line()
    init_logging()

    routes = [
        web.url(r'/', web.RedirectHandler, {'url': '/version'}),
        web.url(r'/version', VersionHandler),
        web.url(r'/render', RenderHandler, {
            'style_host': options.style_host,
            'style_port': options.style_port,
            'http_client': AsyncHTTPClient()
        }),
    ]

    app = web.Application(routes)
    app.listen(options.port)
    logger = get_logger()
    logger.info('Listening on localhost:4096...')
    IOLoop.instance().start()
开发者ID:socrata-platform,项目名称:carto-renderer,代码行数:30,代码来源:service.py


示例18: reset_handlers

    def reset_handlers(cls,application):
        settings = application.settings

        # 重置 handlers
        if settings.get("static_path") :
            path = settings["static_path"]
         
            static_url_prefix = settings.get("static_url_prefix",
                                             "/static/")
            static_handler_class = settings.get("static_handler_class",
                                                StaticFileHandler)
            static_handler_args = settings.get("static_handler_args", {})
            static_handler_args['path'] = path
            for pattern in [re.escape(static_url_prefix) + r"(.*)",
                            r"/(favicon\.ico)", r"/(robots\.txt)"]:

                item = url(pattern, static_handler_class, static_handler_args)
                cls._routes.setdefault('.*$', [])
                if item not in cls._routes['.*$'] :
                    cls._routes['.*$'].insert(0, item) 

        # 404
        item = url(r"/(.+)$", _404Handler)
        if item not in cls._routes['.*$'] :
            cls._routes['.*$'].append(item) 
开发者ID:2life,项目名称:wiki.catke,代码行数:25,代码来源:web.py


示例19: __init__

 def __init__(self):
     urlpatterns = (
         url(r"/image/(\w+\.(?:jpg|png))$", ImageHandler,
             name="image"),
     )
     if options.debug:
       urlpatterns += (
         url(r"/static/(.*)",
             tornado.web.StaticFileHandler, {"path": root("static")}),
       )
     settings = dict(
         cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
         login_url="/auth/login",
         template_path=root("templates"),
         static_path=root("static"),
         static_url_prefix="/static/",
         xsrf_cookies=True,
         # facebook_api_key=options.facebook_api_key,
         # facebook_secret=options.facebook_secret,
         # ui_modules={"Post": PostModule},
         debug=options.debug,
         # autoescape=None,
         compress_response=True,
         )
     super(Application, self).__init__(urlpatterns, **settings)
开发者ID:yxy,项目名称:liveimg,代码行数:25,代码来源:main.py


示例20: main

def main():
    # Creating a Room Handler instance
    rh = RoomHandler()

    # app settings
    settings = {
    "static_path": os.path.join(os.path.dirname(__file__), "static"),
    "static_path": os.path.join(os.path.dirname(__file__), "static"),
    "template_path": os.path.join(os.path.dirname(__file__), "templates"),
    "autoreload": True,
    "debug": True
    }

    # Creating the app instance
    app = tornado.web.Application([
        url(r"/", MainHandler, {'room_handler': rh}, name="index"),
		url(r"/existing", ExistingRooms, {'room_handler': rh},  name="existing"),
        url(r"/ws/(.*)", ClientWSConnection, {'room_handler': rh}),
		],
        **settings
    )

    # Starting the server
    app.listen(8888)
    print 'Clam Chat Server started.'
    print 'listening on 8888 ...'
    tornado.ioloop.IOLoop.instance().start()
开发者ID:nnamdiib,项目名称:chatroom,代码行数:27,代码来源:chat.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python web.Application类代码示例发布时间:2022-05-27
下一篇:
Python util.ObjectDict类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap