pvl/verkko/urls.py
changeset 178 f9f5e669bace
parent 177 b21b2efe1e6c
child 179 706972d09f05
equal deleted inserted replaced
177:b21b2efe1e6c 178:f9f5e669bace
     1 from werkzeug.routing import Map, Rule
       
     2 
       
     3 def rule (string, endpoint, **opts) :
       
     4     return Rule(string, endpoint=endpoint, **opts)
       
     5 
       
     6 # URL -> Handler
       
     7 from pvl.verkko import hosts
       
     8 
       
     9 # index page here :)
       
    10 from pvl.verkko import web
       
    11 
       
    12 class Index (web.Handler) :
       
    13     def render (self) :
       
    14         html = web.html
       
    15 
       
    16         return (
       
    17             html.ul(
       
    18                 html.li(
       
    19                     "DHCP Hosts",
       
    20                     html.ul(
       
    21                         html.li(html.a(href=self.url(hosts.ListHandler, **opts))(title)) for title, opts in hosts.ListHandler.VIEWS
       
    22                     )
       
    23                 ),
       
    24             )
       
    25         )
       
    26 
       
    27 urls = Map((
       
    28     rule('/',                       Index),
       
    29     rule('/hosts/',                 hosts.ListHandler),
       
    30     rule('/hosts/<int:id>',         hosts.ItemHandler),
       
    31     rule('/hosts/realtime',         hosts.RealtimeHandler),
       
    32 ))
       
    33