Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython-lwan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Bryton Lacquement
cython-lwan
Commits
c7fa14b2
Commit
c7fa14b2
authored
Jun 21, 2018
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add /fibonacci handler
parent
4aa9ad4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
interface.c
interface.c
+7
-0
lwan_wrapper.pyx
lwan_wrapper.pyx
+17
-0
No files found.
interface.c
View file @
c7fa14b2
#include <lwan/lwan.h>
extern
int
handle_root
(
struct
lwan_request
*
request
,
struct
lwan_response
*
response
);
extern
int
handle_fibonacci
(
struct
lwan_request
*
request
,
struct
lwan_response
*
response
);
LWAN_HANDLER
(
root
)
{
return
handle_root
(
request
,
response
);
}
LWAN_HANDLER
(
fibonacci
)
{
return
handle_fibonacci
(
request
,
response
);
}
static
int
listen_and_serve
(
void
)
{
const
struct
lwan_url_map
default_map
[]
=
{
{
.
prefix
=
"/"
,
.
handler
=
LWAN_HANDLER_REF
(
root
)
},
{
.
prefix
=
"/fibonacci"
,
.
handler
=
LWAN_HANDLER_REF
(
fibonacci
)
},
{
.
prefix
=
NULL
}
};
struct
lwan
l
;
...
...
lwan_wrapper.pyx
View file @
c7fa14b2
...
...
@@ -19,6 +19,7 @@ cdef extern from "lwan/lwan-strbuf.h":
pass
bint
lwan_strbuf_set_static
(
lwan_strbuf
*
s1
,
const
char
*
s2
,
size_t
sz
)
nogil
bint
lwan_strbuf_printf
(
lwan_strbuf
*
s
,
const
char
*
fmt
,
...)
nogil
cdef
extern
from
"interface.c"
:
int
listen_and_serve
()
nogil
...
...
@@ -34,3 +35,19 @@ cdef public int handle_root(lwan_request *request, lwan_response *response) nogi
lwan_strbuf_set_static
(
response
.
buffer
,
message
,
strlen
(
message
))
return
HTTP_OK
cdef
unsigned
int
fibonacci
(
unsigned
int
n
)
nogil
:
cdef
unsigned
int
i
,
a
,
b
a
,
b
=
0
,
1
for
i
in
range
(
n
):
a
,
b
=
b
,
a
+
b
return
a
cdef
public
int
handle_fibonacci
(
lwan_request
*
request
,
lwan_response
*
response
)
nogil
:
response
.
mime_type
=
"text/plain"
lwan_strbuf_printf
(
response
.
buffer
,
"Fibonacci(10^6) = %u (with overflow)
\
n
"
,
fibonacci
(
1000000
))
return
HTTP_OK
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