Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycfhelpers
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
python-cellframe-modules
pycfhelpers
Commits
210d50f0
Commit
210d50f0
authored
1 year ago
by
boo
Browse files
Options
Downloads
Patches
Plain Diff
fix: http error and pep-8
parent
0da70068
No related branches found
Branches containing commit
No related tags found
1 merge request
!4
Feature 10361
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
node/http/simple.py
+14
-15
14 additions, 15 deletions
node/http/simple.py
with
14 additions
and
15 deletions
node/http/simple.py
+
14
−
15
View file @
210d50f0
from
DAP.Core
import
AppContext
from
DAP.Network
import
Server
,
HttpSimple
,
HttpCode
from
pycfhelpers.node.logging
import
CFLog
...
...
@@ -7,38 +6,38 @@ from typing import Callable
HTTP_REPLY_SIZE_MAX
=
10
*
1024
*
1024
class
CFSimpleHTTPRequest
:
def
__init__
(
self
,
http
:
HttpSimple
):
self
.
http
=
http
@property
def
query
(
self
):
return
self
.
http
.
query
@property
def
url
(
self
):
return
self
.
http
.
urlPath
property
@
property
def
method
(
self
):
return
self
.
http
.
action
property
@
property
def
body
(
self
):
return
self
.
http
.
request
@property
def
client_address
(
self
):
return
self
.
http
.
ipClient
class
CFSimpleHTTPRequestHandler
:
def
__init__
(
self
,
methods
:
list
[
str
],
handler
:
Callable
[[
CFSimpleHTTPRequest
],
tuple
[
bytes
,
int
]]):
class
CFSimpleHTTPRequestHandler
:
def
__init__
(
self
,
methods
:
list
[
str
],
handler
:
Callable
[[
CFSimpleHTTPRequest
],
tuple
[
bytes
,
int
]]):
self
.
handler
=
handler
self
.
methods
=
methods
def
__call__
(
self
,
http
:
HttpSimple
,
response_code
:
HttpCode
):
def
__call__
(
self
,
http
:
HttpSimple
,
response_code
:
HttpCode
):
if
http
.
action
in
self
.
methods
:
res
,
code
=
self
.
handler
(
CFSimpleHTTPRequest
(
http
))
http
.
replyAdd
(
res
)
...
...
@@ -47,18 +46,18 @@ class CFSimpleHTTPRequestHandler:
CFLog
.
notice
(
f
"
Method
{
http
.
action
}
not supported for
{
http
.
urlPath
}
"
)
response_code
.
set
(
405
)
class
CFSimpleHTTPServer
:
def
__init__
(
self
):
self
.
_sc
=
Server
()
AppContext
.
getServer
(
self
.
_sc
)
def
register_uri_handler
(
self
,
uri
:
str
,
handler
:
CFSimpleHTTPRequestHandler
):
HttpSimple
.
addProc
(
self
.
_sc
,
uri
,
HTTP_REPLY_SIZE_MAX
,
handler
)
@staticmethod
def
handler
(
uri
:
str
,
methods
:
list
[
str
]
=
[
"
GET
"
,
]
,
**
kwargs
):
def
handler
(
uri
:
str
,
methods
:
list
[
str
]
=
(
"
GET
"
,
)
,
**
kwargs
):
def
wrapper
(
func
):
CFSimpleHTTPServer
().
register_uri_handler
(
uri
,
CFSimpleHTTPRequestHandler
(
methods
=
methods
,
handler
=
func
))
return
wrapper
return
wrapper
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment