-
-
Save rauchg/8b9bd96888ed8cc0c372 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
#include <iostream> | |
#include <native/native.h> | |
using namespace native::http; | |
int main() { | |
http server; | |
if(!server.listen("0.0.0.0", 8080, [](request& req, response& res) { | |
res.set_status(200); | |
res.set_header("Content-Type", "text/plain"); | |
res.end("Hello World"); | |
})) return 1; // Failed to run server. | |
std::cout << "Server listening on http://0.0.0.0:8080/" << std::endl; | |
return native::run(); | |
} |
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
require('http').createServer(function (req, res) { | |
res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
res.end('Hello World'); | |
}).listen(8080, '0.0.0.0', function () { | |
console.log('Server listening on http://0.0.0.0:8080/'); | |
}); |
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
local HTTP = require("http") | |
HTTP.create_server("0.0.0.0", 8080, function (req, res) | |
local body = "Hello world" | |
res:write_head(200, { | |
["Content-Type"] = "text/plain", | |
["Content-Length"] = #body | |
}) | |
res:finish(body) | |
end) | |
print("Server listening on http://0.0.0.0:8080/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please report any issues to the luvit issue tracker: https://github.com/luvit/luvit/issues