bash / linux / python / / / Django REST Framework / Postgree .
Used versions:
Python 3.8.10 (local - Ubuntu 20.04.2 LTS)
Django 3.2.6 - Docker-compose 1.21.2.
Consuming API: http://127.0.0.1:8000/ API: http://127.0.0.1:8000/api/v1/
Endpoints:
- list http://127.0.0.1:8000/api/v1/foods //Listagem das lojas e Visualização de uma loja específica
- http://127.0.0.1:8000/create/ //Criação de uma nova loja
- http://127.0.0.1:8000/update/int:pk/ //Atualização dos dados de uma loja
- http://127.0.0.1:8000/delete/int:pk // Remoção de uma loja
The first thing to do is to clone the repository:
$ git clone https://github.com/fersoftware/fastfood_indico_api.git
$ cd fastfood_indico_api
Create a virtual environment to install dependencies in and activate it:
$ python3 -m venv venv
$ source env/bin/activate
If an error occurs when running, try the command below:
(venv)$ sudo apt-get install python3-venv
Note the (venv)
in front of the prompt. This indicates that this terminal
session operates in a virtual environment set up by python3-venv
.
Running Django using Docker-Compose
(venv)$ sudo docker-compose up -d --build
`
Create user admin
(venv)$ sudo docker-compose exec web python manage.py createsuperuser
Migrate
(venv)$ sudo docker-compose exec web python manage.py migrate
Makemigrations
(venv)$ sudo docker-compose exec web python manage.py makemigrations
(venv)$ pip install -r requirements.txt
Once pip
has finished downloading the dependencies:
(env)$ cd fastfood_indico_api
(env)$ python manage.py runserver
And navigate to http://0.0.0.0:8000/
.
- This script import data from the Fast_Food_Restaurants_US.csv file into Postgree.
(env)$ python importCSVtoPostgre.py -f Fast_Food_Restaurants_US.csv -t fast-food