09039f55398e9118188ba996d3ce74050de663e9
[project/luci.git] / libs / httpd / host / runluci
1 #!/usr/bin/lua
2 require("luci.httpd")
3 require("luci.httpd.server")
4 require("luci.httpd.handler.file")
5 require("luci.httpd.handler.luci")
6
7 DOCROOT = arg[1]
8 PORT = 8080
9
10
11 serversocket = luci.httpd.Socket("0.0.0.0", PORT)
12
13
14 server  = luci.httpd.server.Server()
15 vhost   = luci.httpd.server.VHost()
16
17 server:set_default_vhost(vhost)
18
19
20 filehandler = luci.httpd.handler.file.Simple(DOCROOT)
21 vhost:set_default_handler(filehandler)
22
23 lucihandler = luci.httpd.handler.luci.Luci()
24 vhost:set_handler("/luci", lucihandler)
25
26 io.stderr:write("Starting LuCI HTTPD on port " .. PORT .. "...\n")
27 io.stderr:write("Point your browser to http://localhost:" .. PORT .. "/luci\n")
28
29 daemon = luci.httpd.Daemon()
30 --daemon.debug = true
31 daemon:register(serversocket, server:create_daemon_handlers())
32 daemon:run()