handy-httpd 3.3.0
Extremely lightweight HTTP server for D.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
handy-httpd
An extremely lightweight HTTP server for the D programming language.
For a complete overview, please visit the wiki.
Here's an example of serving static files from a directory:
import handy_httpd;
import handy_httpd.handlers.file_resolving_handler;
void main() {
new HttpServer(new FileResolvingHandler("static")).start();
}
It's also quite simple to define your own custom request handler. Here's an example of a custom request handler that only responds to the /hello
endpoint:
import handy_httpd;
import handy_httpd.responses;
void main() {
auto s = new HttpServer(simpleHandler((ref request, ref response) {
if (request.url == "/hello") {
response.writeBody("Hello world!");
} else {
response.notFound();
}
}));
s.start();
}
- Registered by Andrew Lalis
- 3.3.0 released 2 years ago
- andrewlalis/handy-httpd
- MIT
- Copyright © 2021, Andrew Lalis
- Authors:
- Dependencies:
- httparsed
- Versions:
-
8.4.1 2024-Aug-02 8.4.0 2024-Apr-16 8.3.2 2024-Feb-16 8.3.1 2024-Feb-14 8.3.0 2024-Jan-30 - Download Stats:
-
-
0 downloads today
-
2 downloads this week
-
34 downloads this month
-
19453 downloads total
-
- Score:
- 2.9
- Short URL:
- handy-httpd.dub.pm