Comments (7)
I'm going to try working on this one at PyCon US 2023 sprints
from adafruit_circuitpython_httpserver.
I am not entirely sure what you mean, but there is already a very simple example:
https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer/blob/main/examples/httpserver_simple_serve.py
If you delete all docstrings, prints etc. it is only 4-5 lines long, not considering connecting to WiFi. If you want it without a handler for "/", it is 2 lines long.
One could for sure save some characters but this would not be a realistic scenario for using this lib.
Correct me if I understood this Issue incorrectly.
from adafruit_circuitpython_httpserver.
The minified version of the example would be something like this:
import os, socketpool, wifi
from adafruit_httpserver.server import HTTPServer
ssid, password = os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD")
wifi.radio.connect(ssid, password)
HTTPServer(socketpool.SocketPool(wifi.radio), "/").serve_forever(str(wifi.radio.ipv4_address))
I believe it should be possible to omit manually connecting to WiFi by using special env vars, making the example even shorter:
import socketpool, wifi
from adafruit_httpserver.server import HTTPServer
HTTPServer(socketpool.SocketPool(wifi.radio), "/").serve_forever(str(wifi.radio.ipv4_address))
but at this stage it kind of misses the point of being an example.
from adafruit_circuitpython_httpserver.
I did see the simple server example, but I thought I could provide another that required a bit less work by the end user, and fit the library standard of having a "_simpletest.py" module in the examples folder. I've submitted a PR for it but let me know if you think it's redundant.
Kinda going for less setup steps rather than less lines of code, if that makes sense
from adafruit_circuitpython_httpserver.
Ok, I see. To be honest I believe it would make more sense to modify existing one, and replace response.send_file("index.html")
with response.send("Hello World")
.
Creating a separate example with only one line modified seems like a overkill for me.
from adafruit_circuitpython_httpserver.
@michalpokusa Thanks, I appreciate the feedback. I can make adjustments to the PR to merge the two examples then.
from adafruit_circuitpython_httpserver.
@michalpokusa I've merged the two examples, and renamed the "simple_serve" example to "simpletest" to adhere to the convention which appears to be in the other CircuitPython libraries and this contributing guide:
https://circuitpython.org/contributing/library-infrastructure-issues
Please let me know if you see any other areas for improvement.
from adafruit_circuitpython_httpserver.
Related Issues (20)
- How do I safely disable all access to filesystem? HOT 1
- Rapid requests causing hangs HOT 2
- PyPi Release not importable
- Setting the hostname - Pico W HOT 2
- mdns setting error - trying to set a custom hostname HOT 5
- Yielding data from an async task to a chunked response HOT 24
- Release notes has bad link to Docs HOT 2
- Submitting empty form, or forms with only checkboxes, causes crash in web server HOT 2
- request.form_data.get(...) returns the string "None" if a field doesn't exist HOT 2
- "ImportError: no module named 'hashlib'" on the WIZnet W5500-EVB-Pico HOT 7
- instructions error HOT 1
- Simple Test (examples/httpserver_simpletest_auto.py) error on M5stack Timer Camera X HOT 2
- CircuitPython 9.0.0 will require SO.REUSEADDR for socket reuse HOT 1
- Airlift Support? HOT 11
- HTTPS Server now works on ESP32-S3 but MemoryError on Pico W and ESP32-S2
- Pico W EOPNOTSUPP On CircuitPython 9.0.0 HOT 2
- HTTPServer stops working on CircuitPython version >= 9.0 HOT 3
- RPI Pico W Circuitpython Webserver on AP HOT 5
- add support for "multipart/x-mixed-replace" (for streaming video) HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_circuitpython_httpserver.