urls.py 290 B

123456789101112131415
  1. from django.http import FileResponse, HttpResponse
  2. from django.urls import path
  3. def helloworld(request):
  4. return HttpResponse('Hello World!')
  5. test_filename = __file__
  6. urlpatterns = [
  7. path('', helloworld),
  8. path('file/', lambda x: FileResponse(open(test_filename, 'rb'))),
  9. ]