> > I tried two things: > > ;;; file-server.el --- serve any files using Emacs Web Server > (lexical-let ((docroot "/home/jwhendy/Desktop/e-web-server-test/")) > (ws-start > (lambda (request) > (with-slots (process headers) request > (let ((path (substring (cdr (assoc :GET headers)) 1))) > (if (ws-in-directory-p docroot path) > (if (file-directory-p path) > (ws-send-directory-list process > (expand-file-name path docroot) "^[^\.]") > (ws-send-file process (expand-file-name path docroot))) > (ws-send-404 process))))) > 9003)) > > - If I go to localhost:9003, I get 404 not found.
Surprising, I don't see that locally, and I don't see how that could be the case. > > - If I go to localhost:9003/personal.org (I threw my non-work notes > file into that directory), it downloads the file. > This is expected. Note, you could serve other file types as well, what this example was meant to illustrate is how the web-server will set the mime-type appropriately based on the file type (e.g., serving foo.jpg with the "image/jpeg" type). If you only care about Org-mode files, maybe look at example 7. > > Next, I replaced the first line with a full path to personal.org: > > (lexical-let ((docroot > "/home/jwhendy/Desktop/e-web-server-test/personal.org")) > This makes no sense. The docroot should be a directory. > > Now I get the following error (in the browser) for localhost:9003: > > Caught Error: (void-function ws-send-directory-list) > > If I do localhost:9003/personal.org, it also downloads the file. > > > I feel I must be drastically overcomplicating this somehow... > I've pushed up a small fix to the directory listing which I originally wrote too quickly last night. If you do want to serve files like this locally then it is probably worth it to update your web-server install and try again. If you do update make sure you stop old servers before starting new ones, e.g., by executing the following. (mapc #'ws-stop ws-servers) > > > Thanks again for persisting with me! Sure thing. Sorry if a bug in my hastily written directory listing made things more confusing than they needed to be. > > John > > [snipped emacs terminology discussion] > -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D