Created
March 15, 2015 21:58
-
-
Save fasterthanlime/4054068d7c640c72c45f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use microhttpd | |
import microhttpd/microhttpd | |
handleRequest: func ( | |
cls: Pointer, | |
connection: MHDConnection, | |
url: CString, method: CString, | |
_version: CString, | |
uploadData: CString, | |
uploadDataSize: SizeT, | |
conCls: Pointer) -> Int { | |
page := "<html><body>Hello, browser!</body></html>" | |
response := MHDResponse createFromBuffer(page size, page toCString(), | |
MHDResponseMemoryMode persistent) | |
ret := connection queueResponse(200, response) | |
response destroy() | |
ret | |
} | |
main: func { | |
port := 4141 | |
daemon := MHDDaemon start( | |
MHDFlag selectInternally, port, | |
null, null, | |
handleRequest&, null, | |
MHDOption end) | |
"Listening on port #{port}" println() | |
stdin readLine() | |
daemon stop() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment