예제 #1
0
파일: urls.py 프로젝트: dwitvliet/CATMAID
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
from adminplus.sites import AdminSitePlus

admin.site = AdminSitePlus()
admin.autodiscover()

# CATMAID
urlpatterns = patterns("", url(r"^", include("catmaid.urls")))

# Admin site
urlpatterns += patterns("", url(r"^admin/", include(admin.site.urls)))

# API Documentation
urlpatterns += patterns(
    "", url(r"^apis/", include("rest_framework_swagger.urls")), url(r"^api-token-auth/", ObtainAuthToken.as_view())
)

if settings.DEBUG:
    urlpatterns += patterns(
        "",
        (r"^static/(?P<path>.*)$", "django.views.static.serve", {"document_root": settings.STATIC_ROOT}),
        # Access to static estensions in debug mode, remove leading slash.
        (
            r"^%s(?P<path>.*)$" % settings.STATIC_EXTENSION_URL[1:],
            "django.views.static.serve",
            {"document_root": settings.STATIC_EXTENSION_ROOT},
        ),
        (
            r"^%s(?P<path>.*)$" % settings.MEDIA_URL.replace(settings.CATMAID_URL, ""),
            "django.views.static.serve",
예제 #2
0
파일: urls.py 프로젝트: catmaid/CATMAID
# CATMAID extensions
urlpatterns += [
    url(r'^ext/{}/'.format(extension), include('{}.urls'.format(extension)))
    for extension in settings.INSTALLED_EXTENSIONS
]

# Admin site
urlpatterns += [
    url(r'^admin/', admin.site.urls)
]

# API Documentation
urlpatterns += [
    url(r'^apis/', SwaggerSchemaView.as_view()),
    url(r'^api-token-auth/', ObtainAuthToken.as_view()),
]

# Serve static files in debug mode and if explicitely requested
if settings.DEBUG or settings.SERVE_STATIC:
    def serve_static(prefix, root):
        return url(r'^%s(?P<path>.*)$' % re.escape(prefix), serve,
                kwargs={'document_root': root})

    urlpatterns += [
        # General static files
        serve_static('static/', settings.STATIC_ROOT),
        # Access to static extensions in debug mode, remove leading slash.
        serve_static(settings.STATIC_EXTENSION_URL[1:], settings.STATIC_EXTENSION_ROOT),
        # Media files, i.e. cropped images or exports
        serve_static(settings.MEDIA_URL.replace(settings.CATMAID_URL, ''),
예제 #3
0
# CATMAID extensions
urlpatterns += [
    url(r'^ext/{}/'.format(extension), include('{}.urls'.format(extension)))
    for extension in settings.INSTALLED_EXTENSIONS
]

# Admin site
urlpatterns += [
    url(r'^admin/', admin.site.urls)
]

# API Documentation
urlpatterns += [
    url(r'^apis/', schema_view),
    url(r'^api-token-auth/', ObtainAuthToken.as_view()),
]

# Serve static files in debug mode and if explicitely requested
if settings.DEBUG or settings.SERVE_STATIC:
    def serve_static(prefix, root):
        return url(r'^%s(?P<path>.*)$' % re.escape(prefix), serve,
                kwargs={'document_root': root})

    urlpatterns += [
        # General static files
        serve_static('static/', settings.STATIC_ROOT),
        # Access to static extensions in debug mode, remove leading slash.
        serve_static(settings.STATIC_EXTENSION_URL[1:], settings.STATIC_EXTENSION_ROOT),
        # Media files, i.e. cropped images or exports
        serve_static(settings.MEDIA_URL.replace(settings.CATMAID_URL, ''),