I have a mesh.obj file and I would like to create an endpoint for it. For example, the endpoint could be of the form ‘path/to/mesh’. How would I do this?
Advertisement
Answer
In your urls.py:
JavaScript
x
2
1
url(r'^test-files/(?P<name>.+)/$', views.test_files, name='test_files'),
2
In your views.py:
JavaScript
1
9
1
from django.http.response import HttpResponse
2
from django.views.decorators.csrf import csrf_exempt
3
4
@csrf_exempt # (Allows file download with POST requests, can be omitted)
5
def test_files(request, name):
6
if name == "myxml":
7
fsock = open("/djangopath/data/static/files/my.xml", "rb")
8
return HttpResponse(fsock)
9