pokeapi/config/urls.py

96 lines
2.4 KiB
Python
Raw Normal View History

2014-12-04 11:11:46 +00:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.views.generic import TemplateView
from django.contrib import admin
admin.autodiscover()
2015-09-06 01:22:06 +00:00
##################################
#
# V1 API setup using Tastypie
#
##################################
2014-12-04 11:11:46 +00:00
from tastypie.api import Api
2014-12-15 10:13:52 +00:00
from pokemon.api import (
2014-12-04 11:11:46 +00:00
PokemonResource, TypeResource, AbilityResource, GameResource,
SpriteResource, DescriptionResource, EggResource, MoveResource,
PokedexResource
)
api_resources = Api()
api_resources.register(PokemonResource())
api_resources.register(AbilityResource())
api_resources.register(TypeResource())
api_resources.register(GameResource())
api_resources.register(SpriteResource())
api_resources.register(DescriptionResource())
api_resources.register(EggResource())
api_resources.register(MoveResource())
api_resources.register(PokedexResource())
2015-09-06 01:22:06 +00:00
#####################################
#
# V2 API setup using Django Rest
#
#####################################
from rest_framework import routers
from pokemon_v2.views import *
2015-09-06 01:22:06 +00:00
router = routers.DefaultRouter()
router.register(r"ability", AbilityResource)
router.register(r"generation", GenerationResource)
2015-09-10 23:02:06 +00:00
router.register(r"language", LanguageResource)
router.register(r"move", MoveResource)
router.register(r"nature", NatureResource)
router.register(r"pokedex", PokedexResource)
router.register(r"pokemon", PokemonResource)
router.register(r"region", RegionResource)
router.register(r"type", TypeResource)
router.register(r"version", VersionResource)
router.register(r"version-group", VersionGroupResource)
2015-09-06 01:22:06 +00:00
###########################
#
# Gotta Get Em' All
#
###########################
2014-12-04 11:11:46 +00:00
urlpatterns = patterns(
2015-09-06 01:22:06 +00:00
2014-12-04 11:11:46 +00:00
'',
2015-09-06 01:22:06 +00:00
2014-12-04 11:11:46 +00:00
url(r'^$', 'config.views.home'),
2015-09-06 01:22:06 +00:00
2014-12-04 11:11:46 +00:00
url(r'^docs/$',
TemplateView.as_view(template_name='pages/docs.html'),
name="documentation"),
2015-09-06 01:22:06 +00:00
2014-12-04 11:11:46 +00:00
url(r'^about/$', 'config.views.about'),
2015-09-06 01:22:06 +00:00
2014-12-04 11:11:46 +00:00
url(r'^admin/', include(admin.site.urls)),
2015-09-06 01:22:06 +00:00
2014-12-04 11:11:46 +00:00
url(r'^api/', include(api_resources.urls)),
2015-09-06 01:22:06 +00:00
url(r'^api/v2/', include(router.urls)),
2014-12-04 11:11:46 +00:00
url(r'^media/(?P<path>.*)',
'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
2015-09-06 01:22:06 +00:00
2014-12-04 11:11:46 +00:00
url(r'^static/(?P<path>.*)',
'django.views.static.serve',
{'document_root': settings.STATIC_ROOT}),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)