A service with both GUI & API interfaces built with Python, Django & FusionCharts.
| License: | MIT |
|---|
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Requires Python3.6+ & PostgreSQL.
$ sudo apt-get install postgresql postgresql-contrib
Create a user to be used later when connecting django with the database.
Set database url:
DATABASE_URL=postgres://username:password@127.0.0.1:5432/databasename.
Set admin url:
DJANGO_ADMIN_URL="admin/"
Set AWS keys:
Since we are not using AWS for storage nor for staticfiles, so we set these variables to None.
DJANGO_AWS_ACCESS_KEY_ID=None DJANGO_AWS_SECRET_ACCESS_KEY=None DJANGO_AWS_STORAGE_BUCKET_NAME=None
Set django secret key:
DJANGO_SECRET_KEY="key"
Set MailGun:
MAILGUN_API_KEY=None MAILGUN_DOMAIN=None
For more settings.
Install all the requirements:
$ pip install -r requirements.txt
Migrate the database:
$ python manage.py migrate
Run the server:
$ python manage.py runserver
To create an superuser account, use this command:
$ python manage.py createsuperuser
The API enables to view, create, delete & update the database. The API is not using any type of authentication to make it simple and easy to test.
Returns all entries in the database.
https://sample-django-123.herokuapp.com/campaign/api/
| Response formats | JSON |
| Requires authentication? | No |
| Name | Description |
|---|---|
| id | database unique id |
| name | name of the campaign |
| country | country's name |
| budget | campaign's budget |
| goal | campaign's goal |
| category | category of campaign |
$ curl --request GET --url 'https://sample-django-123.herokuapp.com/campaign/api/'
[{
"id": 20,
"name": "n2",
"country": "USA",
"budget": 399,
"goal": "Conversion",
"category": "Sports"
},
{
"id": 21,
"name": "n3",
"country": "EGY",
"budget": 149,
"goal": "Awareness",
"category": "Sports"
},
{
"id": 19,
"name": "aaaaa",
"country": "FR",
"budget": 149,
"goal": "rrr",
"category": "Sports"
},
{
"id": 22,
"name": "n99",
"country": "FR",
"budget": 324,
"goal": "Awareness",
"category": "Sports"
}]
Create an entry in the datanase.
https://sample-django-123.herokuapp.com/campaign/api/create/
| Response formats | JSON |
| Requires authentication? | No |
| Name | Description | Required |
|---|---|---|
| id | database unique id | False |
| name | name of the campaign | True |
| country | country's name | True |
| budget | campaign's budget | True |
| goal | campaign's goal | True |
| category | category of campaign | True |
$ curl --header "Content-Type: application/json"\
--request POST \
--data '{"name":"xyz","country":"EGY","budget":"199","goal":"Awareness","category":"Sports"}' \
https://sample-django-123.herokuapp.com/campaign/api/create/
{
"id": 25,
"name": "xyz",
"country": "EGY",
"budget": 199,
"goal": "Awareness",
"category": "Sports"
}
To run the tests, check your test coverage, and generate an HTML coverage report:
$ coverage run manage.py test campaign $ coverage html $ open htmlcov/index.html