Micropython compatibility #2418
Replies: 6 comments 5 replies
-
Hi @Sylvain-BROCAS! Falcon has no hard dependencies, but it still needs a WSGI or ASGI server to run. On normal CPython or PyPy, you can use You could try installing Falcon on your device, and also installing adafruit-circuitpython-wsgi. Then you could try running it along the lines of this example: https://github.com/adafruit/Adafruit_CircuitPython_WSGI/blob/main/examples/wsgi_simpletest.py: import falcon
from adafruit_wsgi.esp32spi_wsgiserver import WSGIServer
class HelloResource:
def on_get(self, req, resp):
resp.media = {'message': 'Hello, World!'}
app = falcon.App()
app.add_route('/hello', HelloResource())
wsgi_server = WSGIServer(8000, application=app)
# print('open this IP in your browser: ', esp.pretty_ip(esp.ip_address))
wsgi_server.start()
while True:
# Our main loop where we have the server poll for incoming requests
try:
wsgi_server.update_poll()
# Could do any other background tasks here, like reading sensors
except (ValueError, RuntimeError) as e:
print("Failed to update server, restarting ESP32\n", e)
# Need to import/initialize this `wifi`...
# wifi.reset()
continue (totally untested) Let us know if you get it to work! |
Beta Was this translation helpful? Give feedback.
-
OK, I can't test right now, but I'll do and share the result as soon as possible |
Beta Was this translation helpful? Give feedback.
-
In the first version of my program, I used microdot (https://github.com/miguelgrinberg/microdot) that seems to run as asgi. I runs well on my ESP32. |
Beta Was this translation helpful? Give feedback.
-
moving to discussion, since there isn't any issue here |
Beta Was this translation helpful? Give feedback.
-
Microdot doesn't run as ASGI though, it can run as ASGI if you have an ASGI server, but unfortunately it doesn't seem to expose its built-in server for general use. |
Beta Was this translation helpful? Give feedback.
-
Hi again @Sylvain-BROCAS, The framework relies on a fair number of stdlib modules that are unavailable:
Some of these like |
Beta Was this translation helpful? Give feedback.
-
Hello,
Thank you for this great module. I'm currently working on an embedded device running micropython on an ESP32.
I'm wondering if falcon is compatible with micropython as it's supported by Cpython.
Thank you for your attention
Beta Was this translation helpful? Give feedback.
All reactions