This is the REST API backend for Rosterra.
- Python 2.7
- git
- curl (for installing)
- PostgreSQL (for the db)
-
Install pip. This might require sudo.
$ curl -O https://bootstrap.pypa.io/get-pip.py $ sudo python get-pip.py
-
Install virtualenv and get it set up and activated.
$ sudo pip install virtualenv $ mkdir ~/rosterra && cd ~/rosterra $ virtualenv venv $ source venv/bin/activate
-
Clone this repo.
$ git clone https://github.com/sdob/rosterra-server.git
-
Install the required Python libraries.
$ cd rosterra-server $ pip install -r requirements.txt
-
Create a Postgres user called
rosterra_user
with passwordpass
, grant the usercreatedb
privileges (for creating the test database), and create a database calledrosterra_db
. The following should work:$ sudo -u postgres psql -c "create user rosterra_user with password 'pass'" $ sudo -u postgres psql -c "alter user rosterra_user with createdb" $ sudo -u postgres psql -c "create database rosterra_db with owner rosterra_user"
-
You should now be able to run the tests.
$ ./manage.py test
-
Before you can run the dev server, you'll need to migrate the database.
$ ./manage.py migrate $ ./manage.py runserver
-
Check that the dev server is running. In another terminal:
$ curl http://localhost:8000/authenticate -d "username=gorman@example.com&password=pass" -w "\n" {"token":"42b854989913c715b7548f4a781eb73bc5dc42e2","user":7} $ export TOKEN=42b854989913c715b7548f4a781eb73bc5dc42e2 $ curl http://localhost:8000/companies -H "Authorization: Token $TOKEN" -w "\n" [{"id":2,"name":"Weyland-Yutani"},{"id":4,"name":"FrobozzCo"}]
-
That's it!