-
Install PostgreSQL (please definite "postgres" as password to the user "postgres" when the installer ask you for) : https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
-
Install PostgreSQL command line tools in case the previous installation isn't enough :
- for linux :
$ sudo apt-get install postgresql
- for mac :
$ brew install postgresql
-
Enable your virtual env
-
Install requisite packages:
$ pip install -r requirements.txt
- Create and update local tables:
$ ./init_db.sh
- The first mdp is your root mdp
- The second is normaly "postgres" if you configure it right during installation
- Run service:
$ python app.py
- Give it a try:
>> import requests, json
>> requests.get('http://localhost:5000/users').json()
[]
>> requests.post('http://localhost:5000/users',
headers={'Content-Type': 'application/json'},
data=json.dumps({'username': 'username'})).json()
{u'id': 1, u'username': u'username', u'uri': u'http://localhost:5000/users/1'}
>> requests.get('http://localhost:5000/users/1').json()
{u'id': 1, u'username': u'username', u'uri': u'http://localhost:5000/users/1'}
>> requests.put('http://localhost:5000/users/1',
headers={'Content-Type': 'application/json'},
data=json.dumps({'username': 'username'})).json()
{u'id': 1, u'username': u'username', u'uri': u'http://localhost:5000/users/1'}
>> requests.delete('http://localhost:5000/users/1')
>> requests.get('http://localhost:5000/users').json()
[]
- At each new release don't forget to run for upgrade the database
$ python manage.py db upgrade
Don't forget that you must pass a "Content-Type: application/json" header along with your request