adafruit / Adafruit_CircuitPython_WSGI

WSGI library for simple web servers
MIT License
20 stars 18 forks source link

Add in support for static asset file serving #6

Open mscosti opened 4 years ago

mscosti commented 4 years ago

A very common use case for a web server is to be able to respond with static asset (files). This is primarily so that if a web browser makes an http request to your webserver, you can respond with a .html file which contains markup for a user interface. This .html file may also include references to other files, namely .js or .css, for front end javascript code and styling.

A common way to achieve this in other frameworks is to specify a particular folder on the server's filesystem, and expose white listed parts or all of its contents. I.e, If a http request comes in and matches the relative path of a file in that folder, then send back an 200 with the contents of that file.

This means that you wouldn't have to manually add a particular route for every static asset you want to serve, and less boiler plate code to read and transmit the asset.


Using Flask as inspiration

Need at minimum

Questions

dhalbert commented 5 months ago

We now recommend using https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer instead, and would like to discontinue supporting this library. Would that library meet your needs? I believe it already addresses what you requested here.