FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
kbengine-httpserver/httpserver/router.py at master · blivenwei/kbengine-httpserver · GitHub
blivenwei
/
kbengine-httpserver
Public
forked from
asynchronoust/kbengine-httpserver
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
kbengine-httpserver
/
httpserver
/
router.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (23 loc) · 666 Bytes
Breadcrumbs
kbengine-httpserver
/
httpserver
/
router.py
Copy path
File metadata and controls
33 lines (23 loc) · 666 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
"""
FileName: router
Author: Tao Hao
@contact: taohaohust@outlook.com
Created time: 2019/5/29
Description:
Changelog:
"""
from
httpserver
.
exceptions
import
MethodNotAllowed
,
NotFound
,
UriDuplicated
class
Router
(
object
):
"""
TODO 1.优化router, 2.加上正则表达式, 3.uri中加入变量支持
"""
def
__init__
(
self
):
self
.
routes_all
=
{}
def
add
(
self
,
uri
,
handler
):
if
uri
not
in
self
.
routes_all
:
self
.
routes_all
[
uri
]
=
handler
else
:
raise
UriDuplicated
(
"uri: %s is duplicated"
%
uri
)
def
get
(
self
,
uri
):
return
self
.
routes_all
.
get
(
uri
)
Back
|
FazBrowse Home
|
New Git URL