routes 订阅
Routes
信息
操作系统
未知
开发语言
Python
开源协议
未知
Routes
Routes是采用Python实现的Rails的URL映射控制. Routes makes it easy to create pretty and concise URL's that are RESTful with little effort. Speedy and dynamic URL generation means you get a URL with minimal cruft (no big dangling query args). Shortcut features like Named Routes cut down on repetitive typing. Current features: Named Routes Sophisticated Route lookup and URL generation Wildcard path's before and after static parts Groupings syntax to allow flexible URL's to accommodate almost any need Sub-domain support built-in Conditional matching based on domain, cookies, HTTP method (RESTful), and more Easily extensible utilizing custom condition functions and route generation functions Extensive unit tests
收起全文
精华内容
下载资源
问答
  • routes

    2021-01-09 11:56:56
    t know for sure if it is an issue at all - I found that there is a way to add routes to Spine.Route but there is no ability to remove them. For example if i want to do something like Spine.Stack and ...
  • Routes

    2017-05-11 17:20:22
    一、关于Routes Routes是一个Rails routes系统的python实现,用来在URLs 和 应用action之间做映射。同时,Routes可用来产生简洁明了的RestFull形式的URLs。Routes做映射时,支持基于域、cookies,HTTP 方法或是预定义...

    一、关于Routes

    Routes是一个Rails routes系统的python实现,用来在URLs 和 应用action之间做映射。同时,Routes可用来产生简洁明了的RestFull形式的URLs。Routes做映射时,支持基于域、cookies,HTTP 方法或是预定义的函数的映射,同时支持子域映射。

    官网文献:http://routes.readthedocs.io/en/latest/

    1. 配置使用Routes

    结合下面例子进行说明routes的使用

    # Setup a mapper
    1. from routes import Mapper
    2. map = Mapper()
    3. map.connect(None, "/error/{action}/{id}", controller="error")
    4. map.connect("home", "/", controller="main", action="index")
    
    # Match a URL, returns a dict or None if no match
    6. result = map.match('/error/myapp/4')
    7. # result == {'controller': 'error', 'action': 'myapp', 'id': '4'}

    行1,2创建一个mapper。
    行3 新建了一条路由规则。根据该规则,对于URL:/error/images/arrow.jpg将产生如下结果:{“controller”: “error”, “action”: “images”, “id”: “arrow.jpg”} 。 { }用来指定里面匹配的字段是什么, : 表示的是匹配字段的格式
    行4和行3不同的是,该条路由规则取了名字,名为“home”.

    行6.7定义了两条路由,该路由是一个正则表达式模式,可匹配所有的URL。

    对于URL “/error/images/arrow.jpg”可以匹配 行3 和行7的规则。在解析URL时,是一条一条的按定义顺序匹配的,因此,该URL使用的是行3的路由规则。

    如果某个URL没有匹配的规则,则mapper返回“match failded” conditions。

    PS:主要函数说明
    (1)connect(*args, **kargs) : 对mapper创建一条新的路由。
    (2)match(url=None, environ=None) :Match a URL against against one of the routes contained.Will return None if no valid match is found.

    2. conditions 使用

    conditions 用于限制进行路由匹配,比如method.

    from routes import Mapper  
    
    map = Mapper()  
    print map  
    print type(map)  
    
    #4.conditions  conditions=dict(method=['GET', 'HEAD'])  
    map.connect('/user/list', controller = 'user', action = 'list', conditions={'method' : ['GET', 'HEAD']})  
    result = map.match('/user/list')  
    
    print result 

    只匹配GET、HEAD请求。
    POST:新建资源 GET:查询资源 PUT:更新资源 DELETE:删除资源 HEAD:验证,包括用户身份和资源的认证

    参考文献:http://blog.csdn.net/li_101357/article/details/52750550#

    3. Requirements

    有时只想要匹配数字,或者匹配可选的几个条目。

    map.connect(r'/blog/{id:\d+}')  
    map.connect(r'/download/{platform:windows|linux/{filename}') 

    \d([0-9])、+(匹配前一个字符一次或多次)、| 正则表达式知识点。
    将上述可以改写成:

    map.connect(r'/blog/{id}', requirements={'id':r'\d+'})  
    map.connect(r'/blog/{platfrom}/{filename}', requirements={'platform':r'windows|linux'})  

    参考文献:http://blog.csdn.net/li_101357/article/details/52750550#

    展开全文
  • Dynamic routes

    2021-01-07 15:31:37
    <div><p>This PR is a work in progress towards adding dynamic routes #77. I validated my understanding of the problem and the solution I sketched out on #77 by first updating the mock Datastore. Then I...
  • <div><p>In <code>RouterImpl, <code>routes</code> and <code>namedRoutes</code> are recalculated every render, but their values only change if <code>Router</code>'s <code>children</code> change, ...
  • Duplicate Routes

    2020-12-28 18:09:24
    <div><p>When you reload routes, duplicates appear here: <pre><code> /routes/routes/view?lct=admin </code></pre> <p>such as duplicates of: <pre><code> /permissions/config </code></pre> <p>Many ...
  • Routes validator

    2021-01-07 07:29:00
    <div><p>We are using Spring Cloud Config for storing Cloud gateway configuration/routes in a yaml file. Is there a way we can validate the routes (syntax and semantics) of the routes in yaml file to ...
  • Restful routes

    2020-12-26 09:05:37
    - New test <code>routes_test.go/TestContentLocation201</code> ensures that all POST routes MUST have a matching GET route and validates the 201 StatusCode and the resource that is identified within ...
  • Routes precedence

    2021-01-08 23:55:59
    <div><p>ran into a couple of things overriding Clearance routes in a recent app. I'm creating an experimental branch, <code>dc-routes-precedence</code> to explore later: <p>...
  • Conflicting routes

    2020-11-28 15:28:57
    domain($domain)</code> option in <code>mapWebRoutes()</code> tenant routes still overwrite <code>GET /</code> and <code>app.index</code> route is not available (because tenant routes are loaded for ...
  • Routes disappeared

    2020-12-01 17:30:55
    <p>After adding more ports all routes disappeared, and they won't generate anymore. <h3>Steps to reproduce <p>Try to generate routes <h3>Expected behaviour <p>Land routes and sea routes should ...
  • Nestes Routes

    2020-12-27 09:29:32
    <div><p>The documentation says nothing about nested routes. Can paloma deal with nested routes?</p><p>该提问来源于开源项目:kbparagua/paloma</p></div>
  • Disallow Routes

    2020-12-28 08:33:15
    <div><p>Looking for sample code regarding routing only to login-logout and tenant routes. <pre><code> private void ConfigRoutes(IRouteBuilder routes) { routes.MapRoute("Default", "{__...
  • Structuring Routes

    2020-12-08 21:22:13
    <div><h2>Creating Separate Routes files for user , stack and posts <h2>Type of issue: <ul><li>[ ] Bug / Error</li><li>[x] Idea / Feature</li><li>[x] Improvement detail</li></ul> <h2>Routes.js files ...
  • Routes config

    2020-12-25 23:49:12
    <div><p>Made routes configurable. <p>Users can now choose their own routes for login, register and user, through config.</p><p>该提问来源于开源项目:ZF-Commons/ZfcUser</p></div>
  • Named Routes

    2020-11-28 20:17:34
    <div><p>Probably one of the biggest things I miss from Rails router is named routes. A lot of times I will build a modular app which gets namespaced under other apps and I need the links to be dynamic...
  • Module Routes

    2020-12-04 19:46:35
    <div><p>Made the module name get automatically added to the front of routes loaded from a module and also added support for <em>root</em> routes in modules</p><p>该提问来源于开源项目:...
  • Root routes

    2021-01-08 05:48:15
    <div><ul><li>Updated readme for root routes</li><li>New RootRoute constraint</li><li>Unit test for constraints</li><li>Config to set root_routes boolean</li></ul>该提问来源于开源项目:...
  • api routes

    2020-12-08 22:25:00
    <div><p>How or Where i can write my own api routes to communicate with my controllers, cuz it works only if i write them in this file vendor\tuandm\laravue-core\src\routes\laravue.php</p><p>该提问来源...
  • Remove routes

    2020-12-26 12:17:45
    <div><p>Since we can now add routes at runtime (using the mutex), I think it would be appropriate to provide a function to remove routes as well. <p>Please excuse me if there is such a function ...
  • 404 Routes

    2020-11-26 18:19:12
    <div><p>Im wondering if there is a simplified method for checking all routes and 404 routes, I have found the following to work, but it would be ideal to have 404 capability available via a fragment: ...
  • external routes

    2020-12-28 06:28:23
    m trying to load a separate routes file. <p>I've tried loading them from my own provider. <pre><code> $routeFile = base_path('/Modules/Test/Routes/web.php'); event(new LoadRouteFile...
  • Extracting routes

    2020-12-02 02:56:04
    to know routes in all Virtual Routes (static, ospf,bgp,...). So, I'm trying to extract all this rules from the FIrewall configuration and I'm getting this error: - * ERROR * * Died on user ...
  • Cache routes

    2020-12-30 14:52:01
    s an easy way to cache our routes. I know that laravel does this and symfony's router component has a <code>cacheDir</code> parameter too and it seems to have an impact on performance. <p>I'm ...
  • Resourceful routes

    2020-12-06 03:44:41
    <div><p>Most of the time I end up using a lot of CRUD resourceful routes. I think that it will be great if we can implement convenient way to add those kind of routes. I like the rails/cake approach, ...
  • Prioritizing routes

    2021-01-08 17:21:39
    <div><p>Is it any support for overriding default routes from the modules? <p>Say if I want to use subdomains instead of subfolder it would be easiest if subdomain.domain....
  • Nested Routes

    2020-11-25 19:16:05
    <div><p>Nested routes are a possible way so solve the problem that we have with button actions. A listing of items of type <code>A</code> would be handled by controller for entity <code>A</code> and ...
  • Routes markdown

    2021-01-09 13:42:17
    <div><p>Implemented routes in markdown, closes #178</p><p>该提问来源于开源项目:ctran/annotate_models</p></div>

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 34,923
精华内容 13,969
关键字:

routes