Mercurial > hg > orthanc
annotate Resources/Samples/WebApplications/DrawingDicomizer.js @ 3730:ae31ba2b09a6
toolbox: LookupTransferSyntax()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Mar 2020 15:06:22 +0100 |
parents | 94f4a18a79cc |
children |
rev | line source |
---|---|
805
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
805
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
805
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
1375
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
10 * License, or (at your option) any later version. |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
11 * |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
15 * General Public License for more details. |
805
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
1375
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
3d76e26b3865
fix licensing terms of samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
805
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 /** |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * Parameters of the HTTP server. |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 **/ |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 var orthanc = { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 host: 'localhost', |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 port: 8042 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 }; |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 var port = 8000; |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 /** |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 * The Web application. |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 **/ |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 var http = require('http'); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 var querystring = require('querystring'); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 var toolbox = require('./NodeToolbox.js'); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 var server = http.createServer(function(req, response) { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 switch (req.method) |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 case 'GET': |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 if (req.url == '/') { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 toolbox.Redirect('/index.html', response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 else if (req.url == '/index.html') { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 toolbox.ServeFile('DrawingDicomizer/index.html', response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 else if (req.url == '/drawing.js') { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 toolbox.ServeFile('DrawingDicomizer/drawing.js', response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 else if (req.url == '/orthanc.js') { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 toolbox.ServeFile('DrawingDicomizer/orthanc.js', response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 else if (req.url == '/jquery.js') { |
2195
c5c77ceb38c0
fix DrawingDicomizer jquery path
Leonardo da Silva Campos <leonardoscampos@gmail.com>
parents:
1900
diff
changeset
|
62 toolbox.ServeFile('../../../OrthancExplorer/libs/jquery.min.js', response); |
805
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 else if (req.url.startsWith('/orthanc')) { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 toolbox.ForwardGetRequest(orthanc, req.url.substr(8), response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 else { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 toolbox.NotFound(response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 break; |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 case 'POST': |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 var body = ''; |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 req.on('data', function (data) { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 body += data; |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 }); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 req.on('end', function () { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 if (req.url == '/orthanc/tools/create-dicom') { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 body = JSON.stringify(querystring.parse(body)); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 toolbox.ForwardPostRequest(orthanc, '/tools/create-dicom', body, response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 else { |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 toolbox.NotFound(response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 }); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 break; |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 default: |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 toolbox.NotFound(response); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 } |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 }); |
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
2197 | 100 |
101 console.log('The demo is running at http://localhost:' + port + '/'); | |
805
56a813a4714d
drawing dicomizer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 server.listen(port); |