Last active
January 28, 2019 14:13
-
-
Save derdesign/4598832 to your computer and use it in GitHub Desktop.
Erlang Web Server using Inets
This file contains hidden or 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
-module(server). | |
-compile([export_all]). | |
% To be used with escript | |
main(_Args) -> | |
ok = inets:start(), | |
{ok, _Pid} = inets:start(httpd, [ | |
{port, 8080}, | |
{server_name, "erlang_server"}, | |
{server_root, filename:absname("")}, | |
{document_root, filename:absname("docroot")}, | |
{bind_address, {0,0,0,0}}, | |
{modules, [mod_alias, mod_get]}, | |
{directory_index, ["index.html"]}, | |
{error_log, "logs/error.log"}, | |
{security_log, "logs/security.log"}, | |
{transfer_log, "logs/transfer.log"} | |
]), | |
io:format("Web Server Started on http://localhost:8080~n"), | |
receive | |
_ -> init:stop() | |
end, | |
ok. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment