$ make clean
$ make migrations
$ make migrations-snippets
$ make migrate
$ make superuser
$ make run
make migrate
make migrations
or (snippets
is an app for this project)
make migrations-snippets
make superuser
make run
~$ curl -u admin -H 'Accept: application/json; indent=4' http://127.0.0.1:8000/users/
make migrations-snippets
for future update Makefile
make migrations MIGRATION_NAME=snippets
make migrate-snippets
make migrate MIGRATION_NAME=snippets
Get a list of snippets
http http://127.0.0.1:8000/snippets/
Get a snippet with id
= 2
http http://127.0.0.1:8000/snippets/2/
If we try to create a snippet without authenticating, we'll get an error:
http POST http://127.0.0.1:8000/snippets/ code="print(123)"
{
"detail": "Authentication credentials were not provided."
}
We can make a successful request by including the correct username and password:
http -a admin:root POST http://127.0.0.1:8000/snippets/ code="print(789)"
{
"id": 1,
"owner": "admin",
"title": "foo",
"code": "print(789)",
"linenos": false,
"language": "python",
"style": "friendly"
}
Create DB
psql -U postgres
CREATE DATABASE pastebinapi_db;
CREATE USER admin WITH PASSWORD 'SXCiKvMy8#4&*W&nNT5kGX&Q2EmUKmx#nu6rDT$djdD4dHfPmnW6JFXx8dqTKhPoVfa7ZZnLmNViC4kp34UpCYg2*@YXEnqB84##fDFxmVG';
GRANT ALL PRIVILEGES ON DATABASE pastebinapi_db TO admin;
Here the Swagger Documentation
Here the Redoc Documentation
Requirements.txt: Create a file listing all your dependencies:
pip freeze > requirements.txt
Create a Procfile in your project root and add:
web: gunicorn PastebinAPI.wsgi --log-file -
Runtime.txt (Optional): Specify your Python version:
python-3.10.0