-
Notifications
You must be signed in to change notification settings - Fork 33
Route refactor and fixes, CPython example
#76
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
Conversation
Route refactor and fixesRoute refactor and fixes ,CPython example
Route refactor and fixes ,CPython exampleRoute refactor and fixes, CPython example
FoamyGuy
left a comment
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.
This looks good to me. I tested a few examples successfully on a Feather ESP32-S3 TFT.
I also tested the new cpython example successfully.
I had to run it with sudo python in my environment for it to work, I was getting Permission Denied tracing back to socket.bind() without sudo. I'm not sure if that is intentional or if there is some way to lower the permission level needed. But it does make sense to me since it's binding to default port on the host PC to control traffic. Maybe not using 0.0.0.0 IP? (I tried 127.0.0.1 as well but it did not change behavior) or perhaps some port other than 80 could have lower permissions perhaps.
Thank you @michalpokusa and @tedder
Updating https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k to 5.0.6 from 5.0.5: > Merge pull request adafruit/Adafruit_CircuitPython_Wiznet5k#125 from FoamyGuy/recv_timeout Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 4.5.1 from 4.5.0: > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#76 from michalpokusa/routes-refactor Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 7.5.8 from 7.5.6: > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#199 from vladak/loop_vs_keep_alive > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#200 from vladak/loop_timeout_vs_socket_timeout > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#184 from rjauquet/rej-fix-loop-blocking Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 1.0.0 from 0.8.2: > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#61 from Gebhartj/Gebhartj-patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
This is a somewhat of a minor change, that does not affect users as it does not change the library's API.
While making on of my projects I noticed that on each request multiple
Routeobjects are created and multipleremethods are called.This PR changes the way
Serverhandles it's routes. New method is more efficient and has some fixes compared to the current way.⭐ Added:
pathinRouteconstructoradafruit_httpserverwith CPython (resolves add cpython example #77)🗑️ Deleted:
_Routesclass as it is no longer needed🪛Fixes:
...and....could be used in other places than between slashes, now the error is raised when trying to do so🛠️ Updated/Changed:
Routenow has separatepathandpath_pattern, the later one is created using separate method for better readabilityRoute.matcheshad docs with typos, after the change docs were updated so it is no longer the caseServer.serve_foreverdefaultspoll_intervalto 0.1s and catchesKeyboardInterrupts during sleeping, it also sleeps only if no request were processed, so it will not affect performance during bursts🏗️ Refactor:
Server's responsibility to find a matchingRoutemethodandpathis passed when finding a matchingRoute, this way we are not creating multiple unnecessaryRouteobjects on every request