Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
6205e69a
Commit
6205e69a
authored
Oct 07, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed python bindings
parent
038f8823
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
13 deletions
+9
-13
example.py
bindings/python/example.py
+9
-9
mongoose.py
bindings/python/mongoose.py
+0
-4
No files found.
bindings/python/example.py
View file @
6205e69a
...
...
@@ -11,24 +11,24 @@ import sys
def
EventHandler
(
event
,
conn
):
info
=
conn
.
info
if
event
==
mongoose
.
HTTP_ERROR
:
conn
.
printf
(
'
%
s'
,
'HTTP/1.0 200 OK
\r\n
'
)
conn
.
printf
(
'
%
s'
,
'Content-Type: text/plain
\r\n\r\n
'
)
conn
.
printf
(
'HTTP error:
%
d
\n
'
,
conn
.
reply_status_code
)
conn
.
write
(
'HTTP/1.0 200 OK
\r\n
'
)
conn
.
write
(
'Content-Type: text/plain
\r\n\r\n
'
)
return
True
elif
event
==
mongoose
.
NEW_REQUEST
and
info
.
uri
==
'/show'
:
conn
.
printf
(
'
%
s'
,
'HTTP/1.0 200 OK
\r\n
'
)
conn
.
printf
(
'
%
s'
,
'Content-Type: text/plain
\r\n\r\n
'
)
conn
.
printf
(
'
%
s
%
s
\n
'
,
info
.
request_method
,
info
.
uri
)
conn
.
write
(
'HTTP/1.0 200 OK
\r\n
'
)
conn
.
write
(
'Content-Type: text/plain
\r\n\r\n
'
)
conn
.
write
(
'[
%
s] [
%
s] [
%
s]
\n
'
%
(
info
.
request_method
,
info
.
uri
,
info
.
query_string
))
if
info
.
request_method
==
'POST'
:
content_len
=
conn
.
get_header
(
'Content-Length'
)
post_data
=
conn
.
read
(
int
(
content_len
))
my_var
=
conn
.
get_var
(
post_data
,
'my_var'
)
else
:
my_var
=
conn
.
get_var
(
info
.
query_string
,
'my_var'
)
conn
.
printf
(
'my_var:
%
s
\n
'
,
my_var
or
'<not set>'
)
conn
.
printf
(
'HEADERS:
\n
'
)
conn
.
write
(
'my_var:
%
s
\n
'
%
(
my_var
or
'<not set>'
)
)
conn
.
write
(
'HEADERS:
\n
'
)
for
header
in
info
.
http_headers
[:
info
.
num_headers
]:
conn
.
printf
(
'
%
s:
%
s
\n
'
,
header
.
name
,
header
.
value
)
conn
.
write
(
'
%
s:
%
s
\n
'
%
(
header
.
name
,
header
.
value
)
)
return
True
elif
event
==
mongoose
.
NEW_REQUEST
and
info
.
uri
==
'/form'
:
conn
.
write
(
'HTTP/1.0 200 OK
\r\n
'
...
...
bindings/python/mongoose.py
View file @
6205e69a
...
...
@@ -135,10 +135,6 @@ class Mongoose(object):
self
.
dll
.
mg_get_cookie
.
restype
=
ctypes
.
c_int
self
.
dll
.
mg_get_option
.
restype
=
ctypes
.
c_char_p
self
.
dll
.
mg_get_request_info
.
restype
=
ctypes
.
POINTER
(
mg_request_info
)
self
.
dll
.
mg_get_user_data
.
restype
=
ctypes
.
c_void_p
self
.
dll
.
mg_get_reply_status_code
.
restype
=
ctypes
.
c_int
self
.
dll
.
mg_get_log_message
.
restype
=
ctypes
.
c_char_p
self
.
dll
.
mg_get_ssl_context
.
restype
=
ctypes
.
c_void_p
if
callback
:
# Create a closure that will be called by the shared library.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment