diff --git a/pkg/httpserver/httpserver.go b/pkg/httpserver/httpserver.go index 53e3f73..27576de 100644 --- a/pkg/httpserver/httpserver.go +++ b/pkg/httpserver/httpserver.go @@ -73,6 +73,12 @@ func New(options *Options) (*HTTPServer, error) { dir = SandboxFileSystem{fs: http.Dir(options.Folder), RootFolder: options.Folder} } + // the python style handler reads the folder directly, without the + // sandbox file system + if options.Python && options.Sandbox { + return nil, errors.New("python style (-py) cannot be used with -sandbox") + } + var httpHandler http.Handler if options.Python { httpHandler = PythonStyle(dir.(http.Dir)) diff --git a/pkg/httpserver/pythonliststyle.go b/pkg/httpserver/pythonliststyle.go index ee6342f..1bda78b 100644 --- a/pkg/httpserver/pythonliststyle.go +++ b/pkg/httpserver/pythonliststyle.go @@ -3,6 +3,7 @@ package httpserver import ( "bytes" "fmt" + "html" "io" "net/http" "os" @@ -82,8 +83,10 @@ func (h *pythonStyleHandler) ServeHTTP(writer http.ResponseWriter, request *http http.ServeFile(writer, request, target) return } else { - _, _ = fmt.Fprintf(writer, htmlHeader, request.URL.Path) - _, _ = fmt.Fprintf(writer, "