Django——HttpResponse()

 1 HttpResponse(content, #返回给视图函数的内容
 2 
 3 content_type=None,#返回给视图函数的类型  text/html文本、text/plain、css、js、xml、json
 4 
 5 status=None,#http响应代码 404 200
 6 
 7 charset=None,
 8 
 9 *args,
10 
11 **kwargs)

举例

1 from django.shortcuts import render
2 from django.http import HttpResponse
3 
4 def index(request):
5     return HttpResponse('<h1>hello world</h1>',content_type='text/plain')
---------------- 生活 > 学习 >> 工作 ----------------
原文地址:https://www.cnblogs.com/jcxioo/p/11606149.html