Closed christabor closed 7 years ago
The package should support this use case, so I'm marking this as a bug. I'll take a look. Thanks for the report.
Hi @christabor! I can recreate this issue with the current development version of Flask-Restless (with some slight modifications to the posted code since the models.py
module was not provided). However, my guess is that the issue is this: the process created by app.run()
receives the request for /ui/
, then issues its own request (via the call to requests.get()
) to the /api/user/1
endpoint. However, the process blocks while waiting for a response from the GET /api/user/1
request, so it cannot serve a response. I don't think this is a problem inherent to Flask-Restless, but a general engineering problem: you can't have a server process block on a request to itself because the process will wait forever for itself to become available.
The solution is to have a separate process that only serves the API. I'm marking this is not a bug. Please let me know if my analysis is inaccurate or if you have any other suggestions!
Yep, make sense. I never intended to use it this way regardless because I would prefer to have the two services (front-end/back-end) run in entirely different processes (containers) but I thought I would mention it. Closing!
When setting up an api, if you register a separate blueprint on the app, where one of that blueprints' routes makes standard requests to the resources (say, for a web UI on the same app), the endpoint itself will basically lag and time out, which requires a restart of the server (and the url never works).
This is probably not an optimal use of the tool, but I figured I'd mention it anyway. A simple workaround is to use two different apps, that can be run in the same source, which I've done successfully, but I wanted to bring it up in case there is some underlying issue with any db transactions.
An example:
app.py
ui.py