Repository navigation
Experimenting with Django integration #42
kkinder
started this conversation in
Show and tell
Replies: 1 comment 1 reply
|
I took a different approach. Still working on it, but my goal was to have one module that contained the data models and their route mapping, and do it in a way that works with micropython. It's looking something like this (still working out details, would love feedback!): my lib - class PyscriptAPI:
# post and get decorators are defined here, other infrastructureuser models - from main import api
@api.request("/api/req", methods=["POST"])
class RequestModel:
field_a: int
field_b: str
field_c: bool
# ...
@api.response("/api/req", methods=["GET", "POST"])
class ResponseModel:
success: bool
resp_field_1: str |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
For me, the plan all along has been that there could be a tidy backend integration. This is my first stab at it. The goal is that you have a frontend chunk and a backend chunk, closely coupled. Eg, from the demo:
Then in the
static/todo.pyfile:It uses json for serialization, with a little tweak to handle datetimes, so it's presumably pretty safe.
EDIT: I guess I forgot the link: https://github.com/kkinder/django-puepy
All reactions