Created
April 27, 2017 06:05
-
-
Save Suor/22f162549fb634e3c3adea518c080eb7 to your computer and use it in GitHub Desktop.
Django local urls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from localurls import Router | |
router = Router() | |
snapshot = router.url('/snapshot/', method='POST') | |
@snapshot.add(query={'action': 'make'}) | |
def snapshot_make(request): | |
pass | |
@snapshot.add(query={'action': 'add'}) | |
def snapshot_add(request): | |
pass | |
# snapshot_router = router.url('/snapshot/', method='POST').add | |
# @snapshot_router.add(query={'action': 'make'}) | |
# def snapshot(request): | |
# pass | |
@router.add('/snapshot/', method='POST', query=lambda m: {'action': m.__name__}) | |
class Snapshot: | |
def make(request): | |
pass | |
def add(request): | |
pass | |
@router.add(lambda m: '/snapshot/%s/' % m.__name__) | |
class Snapshot: | |
def make(request): | |
pass | |
def add(request): | |
pass | |
@router.nest('/snapshot/') | |
class Snapshot: | |
def make(request): | |
pass | |
def add(request): | |
pass | |
# sub='url' (default), sub=method (GET/POST/...), sub=POST.<field> / GET.<field> / REQUEST.<field> | |
@router.add('/snapshot/', method='POST', sub='POST.action') | |
class Snapshot: | |
def make(request): | |
pass | |
def add(request): | |
pass | |
snapshot = router.nest('/snapshot/', method='POST', sub='POST.action') | |
@snapshot.add | |
def make(request): | |
pass | |
@snapshot.add | |
def add(request): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment