views.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:HSISeg 作者: HSISeg 项目源码 文件源码
def image_to_pickle(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_path') or not params.get('output_path'):
            return HttpResponseBadRequest(json.dumps({'error':'image_path and output_path required'}),content_type="application/json")
        try:
            data = get_data_from_image(params.get('image_path'))
            save_to_pickle(data,str(params.get('output_path'))+"/data.pickle")
            return HttpResponse(json.dumps({'success':True}),content_type="application/json")
        except Exception as e:
            return HttpResponseBadRequest(json.dumps({'error':str(e)}),content_type="application/json")
    else:
        raise Http404()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号