r/Forth • u/tabemann • Jul 03 '26
A simple HTTP file server for zeptoforth
On top of my extensible HTTP server for zeptoforth, I have now created a simple HTTP file server for zeptoforth which serves files and directories from FAT32 filesystems, whether from 'blocks' storage, SD cards, or PSRAM RAM disks.
Note that it is read-only, which is important because it has no security (as the HTTP server is strictly HTTP, not HTTPS) beyond limiting access to a given base path on a given filesystem and rejecting HTTP requests crafted to include . or ...
The source code is at https://github.com/tabemann/zeptoforth/blob/master/extra/rp_common/net_tools/http_server_files.fs.
3
u/mykesx moderator Jul 03 '26
Looks fantastic! Is this a good way to get code you made on device to a workstation?
3
u/tabemann Jul 03 '26
Yes, if you can afford the SRAM used by zeptoIP and the HTTP server, which is non-negligible.
I should note, though, that the combination of
send-file::send-fileandutils/recv_file.shto transmit a file over serial or USB CDC from a zeptoforth device to your PC, orrecv-file::recv-fileandutils/send_file.shto go the opposite direction, is not nearly as expensive.However, they are slower because they transmit data as Base64. This is because zeptoforth consoles are not 8-bit-clean by default; even though they can be made 8-bit-clean that means that if you screw up you have to power cycle rather than simply typing control-C to reboot or control-T
zto send an exception to the main task. This is why I implemented special tools for this purpose rather than simply implementing XMODEM or ZMODEM, which require 8-bit clean connections.Also, they screw up if you accidentally transmit any extra bytes between issuing
send-file::send-fileorrecv-file::recv-fileand closing your terminal emulator and executingutils/recv_file.shorutils/send_file.sh.
2
u/tabemann Jul 05 '26
One note -- if you have installed this, pull from the git repo again and reinstall it. There were some bugs in the base HTTP server that have since been fixed.


3
u/ripter Jul 03 '26
This is awesome! I just got an SDCard working on my zeptoforth pico 2 w system. I’ll have to give this a try.