Feature request: REST API handlers
See original GitHub issueI would like to use an existing JustPy app to also provide a few REST API functions. My current attempt goes like this:
import justpy as jp
import starlette.responses
def status_json(request):
return starlette.responses.JSONResponse({'status':'okay'})
jp.Route('/api/status',status_json)
jp.justpy(status_json)
which understandably results in AssertionError: Function did not return a web page
.
Could you please help me hook into scarlette inside JustPy so that the request can return JSON, for some endpoints?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Developing request handlers - Vespa Documentation
Implementing a request handler. Upon receiving a request, the request handler must consume its content, process it, and then return a response. The...
Read more >fabulator/rest-api-handler - GitHub
This library will help you with requests to REST APIs. It uses Fetch API which isn't supported by node and some older browsers...
Read more >Best practices for REST API design - Stack Overflow Blog
In this article, we'll look at how to design REST APIs to be easy to understand for anyone consuming them, future-proof, and secure...
Read more >Creating custom REST resource handler to perform mapping
A REST call requires the creation of a resource handler. The resource handler represents the entry point for resource requests and is annotated...
Read more >REST API Best Practices – REST Endpoint Design Examples
4. Use Status Codes in Error Handling ... You should always use regular HTTP status codes in responses to requests made to your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @elimintz, that is what I found out as well 😃 The API interface is not complex in this case so I’d like to keep it neatly together with pages served by JustPy.
#182 would allow returning
JSONResponse
.