mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
First steps with the api
This commit is contained in:
0
api/__init__.py
Normal file
0
api/__init__.py
Normal file
3
api/admin.py
Normal file
3
api/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
0
api/migrations/__init__.py
Normal file
0
api/migrations/__init__.py
Normal file
3
api/models.py
Normal file
3
api/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
3
api/tests.py
Normal file
3
api/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
16
api/urls.py
Normal file
16
api/urls.py
Normal file
@ -0,0 +1,16 @@
|
||||
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'),
|
||||
|
||||
]
|
2
api/views/__init__.py
Normal file
2
api/views/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .api import *
|
||||
from .serializers import *
|
13
api/views/api.py
Normal file
13
api/views/api.py
Normal file
@ -0,0 +1,13 @@
|
||||
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']))
|
1
api/views/serializers.py
Normal file
1
api/views/serializers.py
Normal file
@ -0,0 +1 @@
|
||||
from rest_framework import serializers
|
Reference in New Issue
Block a user