Open kee007ney opened 6 months ago
from django.http import JsonResponse, HttpResponseRedirect
def my_view(request):
# Check if the request accepts JSON or if the format is explicitly requested as JSON
if 'application/json' in request.headers.get('Accept', '') or request.GET.get('format') == 'json':
data = {'key': 'value'} # Your JSON data here
return JsonResponse(data)
else:
# Redirect to the external React frontend
return HttpResponseRedirect('https://your-react-frontend.com')```
When someone copies their BCO ID and attempts to share it, they're taken to a Django page, which isn't what most people want. A redirect should be set up so that people can go to the object (e.g. builder for drafts and viewer for published).
So for example if someone shares: https://biocomputeobject.org/HIVE_000002/DRAFT and you click on it, you're taken to: https://biocomputeobject.org/builder?https%3A%2F%2Fbiocomputeobject.org%2FHIVE_000002%2FDRAFT=