Commit feb7b468 authored by Sli's avatar Sli

First steps with the api

parent ad36c1c6
from django.contrib import admin
# Register your models here.
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url, include
from api.views import *
from rest_framework import routers
# Router config
router = routers.DefaultRouter()
urlpatterns = [
# API
url(r'^', include(router.urls)),
url(r'^login/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^markdown$', RenderMarkdown, name='api_markdown'),
]
\ No newline at end of file
from .api import *
from .serializers import *
\ No newline at end of file
from rest_framework.response import Response
from rest_framework.decorators import api_view
from core.templatetags.renderer import markdown
@api_view(['GET'])
def RenderMarkdown(request):
"""
Render Markdown
"""
if request.method == 'GET':
return Response(markdown(request.GET['text']))
from rest_framework import serializers
......@@ -39,7 +39,4 @@ urlpatterns = [
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/rev/(?P<rev>[0-9]+)/', PageRevView.as_view(), name='page_rev'),
url(r'^page/(?P<page_name>[a-z0-9/-_]*)/$', PageView.as_view(), name='page'),
# API
url(r'^api/markdown$', render_markdown, name='api_markdown'),
]
......@@ -100,5 +100,3 @@ from .user import *
from .page import *
from .site import *
from .group import *
from .api import *
from core.templatetags.renderer import markdown
from django.http import HttpResponse
def render_markdown(request):
return HttpResponse(markdown(request.GET['text']))
......@@ -51,6 +51,7 @@ INSTALLED_APPS = (
'counter',
'eboutic',
'launderette',
'rest_framework',
'api',
)
......
......@@ -29,5 +29,6 @@ urlpatterns = [
url(r'^accounting/', include('accounting.urls', namespace="accounting", app_name="accounting")),
url(r'^eboutic/', include('eboutic.urls', namespace="eboutic", app_name="eboutic")),
url(r'^launderette/', include('launderette.urls', namespace="launderette", app_name="launderette")),
url(r'^api/', include('api.urls', namespace="api", app_name="api")),
url(r'^admin/', include(admin.site.urls)),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # TODO: remove me for production!!!
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment