https://github.com/pybites/codetips
Little toy project to learn Django Rest Framework (PCC34)
https://github.com/pybites/codetips
Last synced: 2 months ago
JSON representation
Little toy project to learn Django Rest Framework (PCC34)
- Host: GitHub
- URL: https://github.com/pybites/codetips
- Owner: pybites
- Created: 2017-09-08T10:42:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T00:35:52.000Z (over 2 years ago)
- Last Synced: 2025-03-22T17:11:29.490Z (3 months ago)
- Language: Python
- Size: 22.5 KB
- Stars: 2
- Watchers: 0
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## PCC 34 - DRF
[](https://bettercodehub.com/)
A simple API to add coding tips, inspired by @python_tip and following DRF's awesome tutorial (part 1 - 4)
To run it locally:
git clone https://github.com/pybites/codetips
cd codetips
python3 -m venv venv
echo 'export DJANGO_ENV=local' >> venv/bin/activate
echo 'export SECRET_KEY=some-random-string' >> venv/bin/activate
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py runserverGo to `http://127.0.0.1:8000/tips/` in the browser and add some code tips using the user you just created.
Or use [Postman](https://www.getpostman.com/).
Or use `httpie` (included in requirements) from command line:
http -a guest:handl3bar POST http://127.0.0.1:8000/tips/ tip="How to code in Python? >>> python -c 'import this'" (defaults to language=python)
http -a guest:handl3bar POST http://127.0.0.1:8000/tips/ language="javascript" tip="alert('most boring codetip');"
http -a guest:handl3bar POST http://127.0.0.1:8000/tips/ language="javascript2" tip="alert('most boring codetip');" (errors: wrong lang / no dup tip!)Retrieve tips:
http http://127.0.0.1:8000/tips/
http http://127.0.0.1:8000/tips/1/
http http://127.0.0.1:8000/users/
http http://127.0.0.1:8000/users/1/TODO: get it running on Heroku ...