Mercurial > hg > orthanc-book
view Sphinx/source/plugins/stl/nifti.py @ 1123:292479b06402
security: authentication wrt RemoteAccess
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 19 Dec 2024 08:17:02 +0100 |
parents | 5a3c238575f8 |
children |
line wrap: on
line source
import base64 import json import requests with open('colon.nii.gz', 'rb') as f: nifti = f.read() r = requests.post('http://localhost:8042/stl/encode-nifti', json.dumps({ 'Nifti' : 'data:application/octet-stream;base64,' + base64.b64encode(nifti).decode('ascii'), 'ParentStudy' : '6ed7e8a4-60deff42-5e22a424-2128629f-158d0b3a', 'Smooth' : True, 'Resolution' : 256, })) r.raise_for_status() instanceId = r.json() ['ID']