我有一个django视图,它被称为使用一个角度前端控制器,一个图像被传递给它,对它进行一些处理并输出立即生成我想把这个输出呈现给angularjs应用程序,而不是给我的模板.In换句话说,我不想使用任何模板来呈现这个输出给用户,但使用棱角分明。你知道吗
你知道吗应用程序.js你知道吗
$scope.segmentImage = function(image)
{
$http({method:'POST', url:'http://127.0.0.1:8000/image/script_function/', data:{'image': image}})
.then(function successCallback(response)
{
console.log('Image Posted successfully')
},function errorCallback(response)
{
console.log('Image Post failed')
}
)};
你知道吗视图.py你知道吗
from django.shortcuts import render
def segment_image(request):
if request.method == 'GET':
form = segment_form()
else:
if form.is_valid():
info = request.POST['info_name']
output = script_function(info)
''' Here i am calling script_function,passing the POST data info to it'''
return render(request, 'your_app/your_template.html', {
'output': output,
})
return render(request, 'your_app/your_template.html', {
'form': form,
})
'''here info is our image in some format'''
def script_function(info):
'''here goes my main logic'''
x=y=w=h=102
return x,y,w,h
使用js FormData
和后fd
相关问题 更多 >
编程相关推荐