def run_algo(request):
if request.method == 'POST':
try:
params = json.loads(request.body)
except:
return HttpResponseBadRequest(json.dumps({'error':'Json required'}),content_type="application/json")
if not params.get("image_pickle_file_path") or not params.get("algo") or not params.get('cluster_number') or not params.get('output_path'):
return HttpResponseBadRequest(json.dumps({'error':'output_path ,image_pickle_file_path,cluster_number and algo manadatory,only .pickle file accepted, valid algo are '+str(default_params.algo_details.keys())}),content_type="application/json")
pid_element = Results.objects.create(pid=None)
params['id'] = pid_element.id
params = json.dumps(params)
command = "python segment_hsi.py '"+str(params)+"' &"
proc = subprocess.Popen(command,shell=True)
return HttpResponse(json.dumps({'success':True,'task_id':pid_element.id}),content_type="application/json")
else:
raise Http404()
评论列表
文章目录