本文整理汇总了Python中django.shortcuts.HttpResponse.__setitem__方法的典型用法代码示例。如果您正苦于以下问题:Python HttpResponse.__setitem__方法的具体用法?Python HttpResponse.__setitem__怎么用?Python HttpResponse.__setitem__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.shortcuts.HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.__setitem__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addBlog
# 需要导入模块: from django.shortcuts import HttpResponse [as 别名]
# 或者: from django.shortcuts.HttpResponse import __setitem__ [as 别名]
def addBlog(request):
print 's'
blog_title = request.POST.get('blog_title')
blog_content = request.POST.get('blog_content')
blog_tel = request.POST.get('blog_tel')
blog_name = request.POST.get('blog_name')
blog_role = request.POST.get('blog_role')
print blog_title,blog_content,blog_tel,blog_name
blog_time=str(datetime.datetime.now())
session = db.db_createSession()
chars=string.ascii_letters+string.digits
ss=''.join([random.choice(chars) for i in range(4)])
print 'a'
blog_id=blog_tel.encode('utf-8')+ss
status=True
print 'b'
while status:
print 'a'
chars=string.ascii_letters+string.digits
ss=''.join([random.choice(chars) for i in range(4)])
blog_id=blog_tel.encode('utf-8')+ss
print 's'
if check(session,blog_id):
status=False
print 'sds'
blog=Blog()
blog.blog_id=blog_id
blog.blog_tel=blog_tel
if blog_name:
blog.blog_name=blog_name
blog.blog_title=blog_title
blog.blog_content=blog_content
blog.blog_role=blog_role
blog.blog_time=blog_time
blog.blog_status='0'
print 's'
f=request.FILES["blog_img"]
# f=request.GET.get('blog_img')
file_name=blog_id+'.jpg'
print 'sd'
with open('/usr/workspace/mark_repository/news/static/images/'+file_name,'wb+') as destination:
# with open('/Users/Csd/PycharmProjects/lokimo/static/images/'+file_name,'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
print 'sdfsdf'
session.add(blog)
session.commit()
session.close()
response=HttpResponse("succeed")
response.__setitem__("Access-Control-Allow-Origin","*")
return response
示例2: upfile
# 需要导入模块: from django.shortcuts import HttpResponse [as 别名]
# 或者: from django.shortcuts.HttpResponse import __setitem__ [as 别名]
def upfile(request):
file = request.FILES['upfile']
print file.name
with open('/usr/workspace/lokimo/static/UEditor/img/' + file.name, 'wb+') as destination:
# with open('/Users/Csd/Desktop/lokimo_website_git/lokimo/static/UEditor/img/' + file.name, 'wb+') as destination:
for chunk in file.chunks():
destination.write(chunk)
url = file.name
title = file.name[:-4]
original = file.name
print url, title, original
# return HttpResponse("{'url':'" + '/static/UEditor/img/' + file.name + "','title':'" + file.name + "','original':'" + file.name + "','state':'" + "SUCCESS" + "'}",content_type="application/json")
response = HttpResponse(
"{'state': 'SUCCESS', 'url':'" + url + "','title':'" + title + "', 'original':'" + original + "'}")
response.__setitem__("Access-Control-Allow-Origin", "*")
return response
示例3: comprobar_pedido
# 需要导入模块: from django.shortcuts import HttpResponse [as 别名]
# 或者: from django.shortcuts.HttpResponse import __setitem__ [as 别名]
def comprobar_pedido(request, pedido_id):
try:
pedido = Pedido.objects.get(num_pedido = pedido_id)
except Pedido.DoesNotExist:
pedido = None
data = {}
if pedido != None:
try:
certificado = Certificado.objects.get(pedidoC=pedido)
except Certificado.DoesNotExist:
certificado = None
if certificado == None:
motorizado = Motorizado.objects.get(empleado = pedido.motorizado)
data['status'] = "success"
data['key'] = motorizado.identifier
else:
data['status'] = "finish"
else:
data['status'] = "error"
response = HttpResponse(json.dumps(data))
response.__setitem__("Content-type", "application/json")
response.__setitem__("Access-Control-Allow-Origin", "*")
return response