Answer the question
In order to leave comments, you need to log in
How to link django rest framework + nginx + gunicorn?
I want to raise a simple api.
Installed DRF, added a test method to views -> "python manage.py runserver" -> API request from the same machine - it works.
Now I want to make it possible to pull this api not only from the local machine.
I saw somewhere an example with "python manage.py runserver 0.0.0.0:8000" - I tried it, I make a request from the outside - it works (although I don't quite understand why), but oh well - in any case, this is hardly the way that needed.
As far as I understand, you need to use nginx and gunicorn (or equivalents) as in the case with regular sites. Can you help with how the nginx file should look at least roughly? I can't google any guide on how to set up nginx and django rest framework. With regular djnago, there are a lot of examples, but drf is not.
server {
listen 8000;
server_name localhost;
location /getHello/ {
proxy_pass http://127.0.0.1:8000/getHello/;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question