mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 12:49:02 -05:00
basic api
This commit is contained in:
25
cookbook/api.py
Normal file
25
cookbook/api.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import requests
|
||||
import json
|
||||
from .models import Recipe
|
||||
from django.conf import settings
|
||||
from rest_framework.decorators import api_view
|
||||
from rest_framework.response import Response
|
||||
|
||||
|
||||
@api_view(['GET'])
|
||||
def get_file_link(request, recipe_id):
|
||||
recipe = Recipe.objects.get(id=recipe_id)
|
||||
|
||||
url = "https://api.dropboxapi.com/2/sharing/create_shared_link"
|
||||
|
||||
headers = {
|
||||
"Authorization": "Bearer " + settings.DROPBOX_API_KEY,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
data = {
|
||||
"path": ""
|
||||
}
|
||||
|
||||
r = requests.post(url, headers=headers, data=json.dumps(data))
|
||||
return Response(r.content)
|
||||
Reference in New Issue
Block a user