Travel Mate Server (Project: Nomad)
Django 2.0 server for Travel Mate
Contribute
- For new feature request in the app, open a new feature request on the main repository
- For reporting bug in existing APIs, open a new issue on this repository
Local setup instructions
- Clone the project from source
shell git clone https://github.com/project-travel-mate/server && cd server - Setup virtual environment
shell pip install virtualenv virtualenv venv --python=python3.6 source venv/bin/activate - Install all dependencies
shell pip install -r requirements.txt - Setup Postgres database and user (assuming Postgres is already installed on system; See postgres setup instructions)
For Linux-
$ sudo -u postgres createuser nomad
$ sudo -u postgres createdb nomad
$ sudo -u postgres psql
psql=# alter user nomad with encrypted password 'pass';
psql=# grant all privileges on database nomad to nomad ;
For Windows-
The complete path>psql -U postgres -h localhost
Password:The one given during setup of postgres.
postgres=# create database nomad;
postgres=# create user nomad;
postgres=# alter user nomad with encrypted password 'pass';
postgres=# grant all privileges on database nomad to nomad ;
Database migrations
python manage.py makemigrations python manage.py migrateRun Tests
python manage.py testFinally! Run server
python manage.py runserver
Open localhost:8000
Working with authenticated APIs
You would need to have a registered user, with which you can generate a authentication token. Follow the following steps to generate a token (You can download Postman client to make the following POST calls) Reference: TokenAuthentication API docs
- Make a POST call to
/api/sign-upwith 4 form-data body objects:email,password,firstname,lastname. You should get "Successfully registered" response with 201 status code. - Make a POST call to
/api/sign-inwith 2 form-data body objects:username(which is your email Id you used for sign up),password. You will get a token in JSON response, store it somewhere. - For making any subsequent request, use the above token by sending it as an "Authorization HTTP Header", eg:
Authorization: Token <your token>
Log in or sign up for Devpost to join the conversation.