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