mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 06:04:18 +00:00
Merge branch 'theoperatore-cors-headers-api'
This commit is contained in:
commit
3b38fe9aeb
5 changed files with 34 additions and 2 deletions
3
Makefile
3
Makefile
|
@ -12,7 +12,8 @@ serve:
|
|||
python manage.py runserver --settings=config.local
|
||||
|
||||
test:
|
||||
python manage.py test pokemon --settings=config.local
|
||||
python manage.py test pokemon_v1 --settings=config.local
|
||||
python manage.py test pokemon_v2 --settings=config.local
|
||||
|
||||
clean:
|
||||
rm -rf *.pyc
|
||||
|
|
|
@ -4,7 +4,6 @@ import os
|
|||
|
||||
PROJECT_ROOT = Path(__file__).ancestor(2)
|
||||
|
||||
|
||||
DEBUG = False
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
|
@ -62,6 +61,7 @@ TEMPLATE_LOADERS = (
|
|||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
|
@ -119,9 +119,15 @@ INSTALLED_APPS = (
|
|||
'django.contrib.staticfiles',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.humanize',
|
||||
'corsheaders'
|
||||
) + CUSTOM_APPS
|
||||
|
||||
|
||||
API_LIMIT_PER_PAGE = 1
|
||||
|
||||
TASTYPIE_DEFAULT_FORMATS = ['json', 'xml']
|
||||
|
||||
CORS_ORIGIN_ALLOW_ALL = True
|
||||
CORS_ALLOW_METHODS = (
|
||||
'GET'
|
||||
)
|
||||
|
|
|
@ -1,2 +1,14 @@
|
|||
from __future__ import unicode_literals
|
||||
from django.test import TestCase
|
||||
|
||||
class HeaderTest(TestCase):
|
||||
|
||||
def test_pokemon(self):
|
||||
|
||||
response = self.client.get(
|
||||
'/api/v1/pokemon/1/',
|
||||
HTTP_ORIGIN="http://pokemon.com"
|
||||
)
|
||||
|
||||
self.assertEqual(response['Access-Control-Allow-Origin'], '*')
|
||||
|
||||
|
|
|
@ -2,3 +2,15 @@ from __future__ import unicode_literals
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
|
||||
class HeaderTest(TestCase):
|
||||
|
||||
def test_pokemon(self):
|
||||
|
||||
response = self.client.get(
|
||||
'/api/v2/pokemon/1/',
|
||||
HTTP_ORIGIN="http://pokemon.com"
|
||||
)
|
||||
|
||||
self.assertEqual(response['Access-Control-Allow-Origin'], '*')
|
||||
|
||||
|
|
|
@ -17,3 +17,4 @@ python-mimeparse==0.1.4
|
|||
simplejson==3.6.5
|
||||
six==1.8.0
|
||||
wsgiref==0.1.2
|
||||
django-cors-headers=0.13
|
||||
|
|
Loading…
Reference in a new issue