Skip to content
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

Merged
merged 5 commits into from
Apr 25, 2023

Conversation

jrrickerson
Copy link
Contributor

@jrrickerson jrrickerson commented Apr 25, 2023

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.

Many of the other CircuitPython libraries use the "simpletest"
nomenclature for their examples - rename the simplest example to match
the convention.
Copy link
Contributor

@FoamyGuy FoamyGuy left a 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.

@@ -21,16 +21,17 @@
print("Connected to", ssid)

pool = socketpool.SocketPool(wifi.radio)
server = HTTPServer(pool, "/static")
server = HTTPServer(pool, "")
Copy link
Contributor

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".

Copy link
Contributor Author

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.

@jrrickerson jrrickerson force-pushed the add_simpletest_example branch from 0268767 to 6e1926a Compare April 25, 2023 21:09
@jrrickerson jrrickerson requested a review from FoamyGuy April 25, 2023 21:22
Copy link
Contributor

@FoamyGuy FoamyGuy left a 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.

@FoamyGuy FoamyGuy merged commit 6df991b into adafruit:main Apr 25, 2023
@michalpokusa
Copy link
Contributor

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.

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 26, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create an httpserver_simpletest example
3 participants