File: urls.py

package info (click to toggle)
python-django 3%3A6.0~beta1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 62,252 kB
  • sloc: python: 371,056; javascript: 19,376; xml: 211; makefile: 187; sh: 28
file content (19 lines) | stat: -rw-r--r-- 414 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from django.http import FileResponse, HttpResponse
from django.urls import path


def helloworld(request):
    return HttpResponse("Hello World!")


def cookie(request):
    response = HttpResponse("Hello World!")
    response.set_cookie("key", "value")
    return response


urlpatterns = [
    path("", helloworld),
    path("cookie/", cookie),
    path("file/", lambda x: FileResponse(open(__file__, "rb"))),
]