mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	This also aligned the Set-Cookie logic in the WSGIHandler and ASGIHandler. Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
		
			
				
	
	
		
			20 lines
		
	
	
		
			414 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			414 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 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"))),
 | |
| ]
 |