Hello world/Web server: Difference between revisions
Content added Content deleted
(Changed to use builtin HTTP server) |
m (Corrected typo, better names.) |
||
Line 333: | Line 333: | ||
-module( hello_world_web_server ). |
-module( hello_world_web_server ). |
||
-export( [do/1, |
-export( [do/1, httpd_start/2, httpd_stop/1, task/0] ). |
||
do( _Data ) -> |
do( _Data ) -> |
||
{proceed, [{response,{200,"Goodbye, World!"}}]}. |
{proceed, [{response,{200,"Goodbye, World!"}}]}. |
||
httpd_start( Port, Module ) -> |
|||
Arguments = [{bind_address, "localhost"}, {port, Port}, {ipfamily, inet}, |
Arguments = [{bind_address, "localhost"}, {port, Port}, {ipfamily, inet}, |
||
{modules, [Module]}, |
{modules, [Module]}, |
||
Line 345: | Line 345: | ||
Pid. |
Pid. |
||
httpd_stop( Pid ) -> |
|||
inets:stop( stand_alone, Pid ). |
inets:stop( stand_alone, Pid ). |
||
task() -> |
task() -> |
||
Pid = |
Pid = httpd_start( 8080, ?MODULE ), |
||
timer:sleep( |
timer:sleep( 30000 ), |
||
httpd_stop( Pid ). |
|||
</lang> |
</lang> |
||