79 lines
2.1 KiB
Elixir
79 lines
2.1 KiB
Elixir
|
|
--# Web Server built with Glade
|
|
|
|
include GtkEngine.e
|
|
|
|
-- You may need to change the following line if you use a terminal other
|
|
-- than gnome-terminal. This is only necessary if you want to use the
|
|
-- tail -f option to display on-going connection requests;
|
|
|
|
constant term = "gnome-terminal --title='SERVER LOG' --window-with-profile=logview -e "
|
|
|
|
add(builder,"webserver.glade")
|
|
set("ip","text",get_net_address())
|
|
|
|
main()
|
|
|
|
--------------------------------------
|
|
global function on_help_button_clicked()
|
|
--------------------------------------
|
|
show_uri(sprintf("file:///%s",
|
|
{canonical_path("~/demos/documentation/ServerHelp.html")}))
|
|
return 1
|
|
end function
|
|
|
|
-----------------------------------------------------------------------
|
|
global function on_log_file_icon_press(atom self)
|
|
-----------------------------------------------------------------------
|
|
set(self,"text","")
|
|
return 1
|
|
end function
|
|
|
|
------------------------------------------------------------------------
|
|
global function on_ok_button_clicked(atom ctl, atom data)
|
|
------------------------------------------------------------------------
|
|
object server = canonical_path("~/demos/examples/httpd.ex")
|
|
object logfilename = get("log_file","text")
|
|
|
|
object path = get("filechooserbutton1","filename")
|
|
if atom(path) then -- nothing chosen
|
|
Warn(,,"Must select a root file path!")
|
|
return 1
|
|
end if
|
|
|
|
-- build a command string to pass to httpd.ex;
|
|
object params = sprintf("eui %s -bind %s:%s ",
|
|
{server,get("ip","text"),get("port","text")})
|
|
|
|
if length(path) > 0 then
|
|
params &= sprintf("-root '%s' ",{canonical_path(path)})
|
|
end if
|
|
|
|
if length(logfilename) > 0 then
|
|
params &= sprintf("-log %s ",{logfilename})
|
|
end if
|
|
|
|
if get("sort","active") then
|
|
params &= " -s "
|
|
end if
|
|
|
|
if get("show_hidden","active") then
|
|
params &=" -h "
|
|
end if
|
|
|
|
if get("show_full_request","active") then
|
|
params &= " -r "
|
|
end if
|
|
|
|
params &= " & "
|
|
|
|
if get("tail_f","active") then -- open a term to tail the log
|
|
system_exec(sprintf("%s 'tail -f %s' & ",{term,logfilename}),0)
|
|
end if
|
|
|
|
system_exec(params)
|
|
|
|
return 1
|
|
end function
|
|
|