https://github.com/drager/toerh
RESTful API written in Python with Django
https://github.com/drager/toerh
Last synced: 3 months ago
JSON representation
RESTful API written in Python with Django
- Host: GitHub
- URL: https://github.com/drager/toerh
- Owner: drager
- Created: 2015-08-01T12:20:16.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-08-01T12:31:55.000Z (almost 11 years ago)
- Last Synced: 2025-03-20T17:52:31.317Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 457 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
TOERH
===========
[](https://travis-ci.org/drager/toerh)
[](https://coveralls.io/r/drager/toerh)
# API
See [api.md](https://github.com/drager/toerh/blob/master/api.md)
## Postman
Postman collection can be found [here](https://github.com/drager/toerh/blob/master/API.json.postman_collection)
# Run the application
## Get the project
First of all clone this repository: `git clone https://github.com/drager/toerh.git`
You also need to set `TOERH_DJANGO_SECRET_KEY`
You can set it like this in unix-systems:
`export TOERH_DJANGO_SECRET_KEY='@v9c-4ymi$o6xk@m24c5hy5)7vrme6_qk_pbd*7+p(!trld@o%'`
(You can use that key since it's used for Travis).
## Elasticsearch
You'll need to have elasticsearch installed.
http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_installing_elasticsearch.html
## Dependencies
[Python version >= 3.0](https://www.python.org/downloads/)
Latest version of [pip](https://pip.pypa.io/en/latest/installing.html)
Check `requirements.txt` for more dependencies
### Install dependencies
To install all the requirements for this project just run: `pip install -r requirements.txt`.
(given that you have Python and pip installed).
## Database
To get the database up and running with the latest migrations and so on just type:
* `python manage.py syncdb`
* `python manage.py makemigrations`
* `python manage.py migrate`
and then the database should be just fine.
### Factories
To seed the database with some nice data run: `python manage.py shell`
then type: `from positioningservice.tests.factories import *` so all our factories get imported.
#### Positions
After import type: `PositionFactory()` and a position will be created.
#### Events
After import type: `EventFactory()` and a event will be created. If we want to have some tags related to that
event we need to do this instead:
```
tag1 = TagFactory()
tag2 = TagFactory()
EventFactory.create(tags=(tag1, tag2))
```
#### Tags
After import type: `TagFactory()` and a tag will be created.
## Run it
locate to `path/to/toerh/` then just run Python's built-in server using the command: `python manage.py runserver` and the application will be served at `http://localhost:8000/`
# Using the API
First of you need to register an account. After that sign in and create a new token.
After successfully set up your account and your token you can make requests as follows:
``curl -X GET http://127.0.0.1:8000/api/v1/positions/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'``
# Admin
The admin interface is located at: `http://localhost:8000/admin/`, login with user created when `python manage.py syncdb` (superuser) was run.