a Django-based indieweb.org site https://00dani.me/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
824 B

import json
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_http_methods
from lemonauth import tokens
from .create import create
from .delete import delete
from .query import query
actions = {
'create': create,
'delete': delete,
}
@csrf_exempt
@require_http_methods(['GET', 'HEAD', 'POST'])
def micropub(request):
request.token = tokens.auth(request)
if request.method in ('GET', 'HEAD'):
return query(request)
action = request.POST.get('action', 'create')
if request.content_type == 'application/json':
request.json = json.load(request)
action = request.json.get('action', 'create')
if action not in actions:
raise error.bad_req('unknown action: {}'.format(action))
return actions[action](request)