-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a bare minimum simpletest example #51
Conversation
Many of the other CircuitPython libraries use the "simpletest" nomenclature for their examples - rename the simplest example to match the convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this.
I think we want to keep the root path argument set to it's old value.
examples/httpserver_simpletest.py
Outdated
@@ -21,16 +21,17 @@ | |||
print("Connected to", ssid) | |||
|
|||
pool = socketpool.SocketPool(wifi.radio) | |||
server = HTTPServer(pool, "/static") | |||
server = HTTPServer(pool, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the "/static"
value for the root_path parameter.
Setting it to empty means that files in the root of the CIRCUITPY drive will be served which is potential security concern since settings.toml would get served.
The library was just recently updated to add additional restrictions to prevent that, so best practice is definitely to use a specific directory for the root path being served.
Even in cases where there is no static content used it can still be set to "/static"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally makes sense, thanks for the feedback. I'll get that updated shortly.
0268767
to
6e1926a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @jrrickerson!
These changes look good to me. I tested it successfully on a Feather S2 TFT.
Perhaps in the future we can add a new example that does return a static HTML file and include a sample file with it so that people have a starting point if they want to serve static web pages from file.
I am currently working on 4.0.0 with a few new features, I will be updating examples to show them so I can add that then. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_IRRemote to 4.1.14 from 4.1.13: > Merge pull request adafruit/Adafruit_CircuitPython_IRRemote#64 from dhalbert/handle-failedtodecode Updating https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS to 4.5.8 from 4.5.7: > Merge pull request adafruit/Adafruit_CircuitPython_LSM6DS#60 from zachariahpifer/fix_linear_and_angular_rates > Add upload url to release action > Add .venv to .gitignore Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 3.0.2 from 3.0.1: > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#51 from jrrickerson/add_simpletest_example Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 1.17.1 from 1.17.0: > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#66 from matt-land/remove-type-changes > Add upload url to release action Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
Create the simplest of simple tests for the HTTPServer by just returning a static plaintext string.
The user does not need to create a directory or HTML file or anything.
Fixes #50
NOTE: This has not yet been tested on hardware due to lack of availability.