annotate Sphinx/source/plugins/python/authorization-2.py @ 1113:a588960a72e5 default tip

spelling
author Alain Mazy <am@orthanc.team>
date Mon, 28 Oct 2024 09:23:08 +0100
parents ba2403ebd4b7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
704
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 import json
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 import orthanc
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 import requests
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 def Filter(uri, **request):
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 body = {
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 'uri' : uri,
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 'headers' : request['headers']
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 }
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 r = requests.post('http://localhost:8000/authorize',
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 data = json.dumps(body))
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 return r.json() ['granted'] # Must be a Boolean
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
ba2403ebd4b7 moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 orthanc.RegisterIncomingHttpRequestFilter(Filter)