Quick Question about the Serve Folders Plug-In

It apparently can support other MIME types ?

The source has this for defaults. Mostly interested in .pdf, video and audio formats.

static void RegisterDefaultExtensions() {

extensions_[“css”] = “text/css”;
extensions_[“gif”] = “image/gif”;
extensions_[“html”] = “text/html”;

extensions_[“jpeg”] = “image/jpeg”;

extensions_[“jpg”] = “image/jpeg”;

extensions_[“js”] = “application/javascript”;
extensions_[“json”] = “application/json”;

extensions_[“nexe”] = “application/x-nacl”;

extensions_[“nmf”] = “application/json”;

extensions_[“pexe”] = “application/x-pnacl”;

extensions_[“png”] = “image/png”;

extensions_[“svg”] = “image/svg+xml”;
extensions_[“wasm”] = “application/wasm”;
extensions_[“woff”] = “application/x-font-woff”;

extensions_[“xml”] = “application/xml”;
}

Also, not sure if this pertains to the Embedded CivetWeb:

http://civetweb.github.io/civetweb/UserManual.html

It has some stuff in there about how to use a cgi interpreter and about general configuration. It sounds like it might be able to serve PHP, PERL and perhaps other languages, like Python ?

http://civetweb.github.io/civetweb/UserManual.html

e.g.

Guess that answers the first part:

https://book.orthanc-server.com/plugins/serve-folders.html

“ServeFolders” : {
“AllowCache” : false,

“GenerateETag” : true,

“Extensions” : {

“.mp4” : “video/mp4”
},

“Folders” : { “/fosdem” : “/home/jodogne/WWW” }

}

1- As written in the documentation, there is an “Extensions” option to register additional MIME types:
https://book.orthanc-server.com/plugins/serve-folders.html#advanced-usage

https://hg.orthanc-server.com/orthanc/file/Orthanc-1.7.2/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp#l320

2- Don’t confuse the standalone civetweb server, and the embedded civetweb server. Orthanc uses the embedded civetweb server, and doesn’t support CGI stuff. You can achieve the same goal as CGI by creating plugins (C/C++/Python) that add new routes in the REST API.

3- Yes, the interface has changed, and there’s nothing I can do about this.

Sébastien,

Thanks a lot for that all. Took awhile to setup, but I got it running using the ServeFolders Plug-in. I was able to relatively easily convert the PHP pages into a single page WebApp where I’m just making an AJAX call to get the data, and then populating a layout defined with plain JS and HTML so that it renders a list of studies pretty much like I had before. Actually pretty easy because I was using an MVC framework before, just replace:

‘. . .’ . $phpparam->name . '

. . . ’ with ‘. . .
’ + object.name + '
. . . ’

The HTML layout and CSS are basically unchanged, just a different way to populate the data.

I’m just using plain JS to populate a template, but something like Vue.JS and axios might be easier and better, or React, but I don’t know that. Using jQuery for now. Looks like you can just using AJAX to make the API calls ? The thing below apparently works with my plug-in. Can you pretty much make all of the REST API calls using AJAX ?

I have a pagination Widget in PHP. Probably not wise to return HTML from the python script, but I might actually try that so that the widget can just be put on the page from the response.

function searchOrthanc() {

var query = {};
query.Level = “Study”; // only Study for /studies/page for now, otherwise tools/find
query.Query = {};
//query.Query.PatientName = “";
query.Query.PatientID = “DEV0000001”;
//query.Query.StudyDate = “”; //e.g. 20150705
//query.Query.ModalitiesInStudy = "
”; //e.g. CT, MRI
//query.Query.SpecificCharacterSet = “ISO_IR 192”;
//query.Query.AccessionNumber = “";
//query.Query.StudyDescription = "
”;
//query.Query.PatientBirthDate = “”;
//query.Query.PatientSex = “";
query.Expand = true;
query.MetaData = {};
query.MetaData.LastUpdate = "
”;
query.pagenumber = 2;
query.itemsperpage =2;
query.sortparam = “AccessionNumber”;
query.reverse = 0;

form = $(“#searchform”);

$.ajax({

url: ‘http://localhost:8042/studies/page’, //. https://sias.dev:8443/studies/page’, works with proxy also.
type: ‘POST’,
dataType: ‘json’,
contentType: ‘application/json; charset=utf-8’,
data: JSON.stringify(query),
beforeSend: function(e) {
$(“#spinner”).css(“display”, “block”);
},
})
.done(function(data, textStatus, jqXHR) {

showStudies(data);
//$(“#studieswrapper”).html(data.paginator + data.html); // for pagination, old code
colorrows($(“#studieswrapper .worklist”));
})
.fail(function( jqXHR, textStatus, errorThrown) {
})
.always(function(jqXHR, textStatus) {
$(“#spinner”).css(“display”, “none”);
});
}

Response is, which is what I what. Might work on a pagination demo now using the ServeFolders. I actually works localhost and with my proxy.

[
{
“count”: 4
},
{
“pagenumber”: 2
},
{
“offset”: 2
},
{
“limit”: 2
},
{
“results”: 2
},
{
“IsStable”: true,
“LastUpdate”: “20200627T183247”,
“PatientMainDicomTags”: {
“PatientBirthDate”: “19571116”,
“PatientSex”: “M”,
“PatientID”: “DEV0000001”,
“PatientName”: “SCOTTI^STEPHEN^D^^”
},
“Series”: [
“e46bfef4-2b166666-468cc957-4b942aa8-3a5c6ef8”
],
“ParentPatient”: “fa21ff2d-33e9b60a-daedf6a0-64d018da-682fd0a4”,
“MainDicomTags”: {
“AccessionNumber”: “DEVACC00000006”,
“StudyDate”: “20190829”,
“StudyDescription”: “XR HIP LT 1 VW”,
“InstitutionName”: “MHealth CSC”,
“ReferringPhysicianName”: “2VASKE^SHANNON^M^^”,
“RequestingPhysician”: “2VASKE^SHANNON^M^^”,
“StudyTime”: “090425”,
“StudyID”: “UC4839619”,
“StudyInstanceUID”: “2.16.840.1.114151.1052214956401694179114379854103077382390190829”
},
“Type”: “Study”,
“ID”: “e8263ed6-56adfc56-a9951260-db8c21f3-c78d7103”,
“Metadata”: {
“LastUpdate”: “20200627T183247”
}
},
{
“IsStable”: true,
“LastUpdate”: “20200627T183258”,
“PatientMainDicomTags”: {
“PatientBirthDate”: “19571116”,
“PatientSex”: “M”,
“PatientID”: “DEV0000001”,
“PatientName”: “SCOTTI^STEPHEN^D^^”
},
“Series”: [
“724c74e6-05cc6cc4-62c9c830-1bfda76c-3a435438”,
“ab78c679-ef037b0a-c267a1cc-dac2dfe7-456d1a3c”,
“8bccacc7-d470b154-446c649d-2f08a482-b18cd25d”
],
“ParentPatient”: “fa21ff2d-33e9b60a-daedf6a0-64d018da-682fd0a4”,
“MainDicomTags”: {
“AccessionNumber”: “DEVACC00000007”,
“StudyDate”: “20190829”,
“StudyDescription”: “XR KNEE RT 3 VW”,
“InstitutionName”: “MHealth CSC”,
“ReferringPhysicianName”: “2VASKE^SHANNON^M^^”,
“RequestingPhysician”: “2VASKE^SHANNON^M^^”,
“StudyTime”: “083425”,
“StudyID”: “UC4839464”,
“StudyInstanceUID”: “2.16.840.1.114151.2411984198229487379168635092719400577270190829”
},
“Type”: “Study”,
“ID”: “86e1a292-07ffb90a-50b2d752-3074f6bd-6895e89a”,
“Metadata”: {
“LastUpdate”: “20200627T183258”
}
}
]

I might have some questions later regarding the Python script I’ve been working on, but not yet. Have something else to work on now.

Thanks. Trying to deploy to a VPS server. It is running as a reverse proxy with NGINX. Initially, I was getting a CORS error, but I changed the configutation and now I’m getting a 405 error with a different message.

W0815 17:24:57.649850 main.cpp:804] Orthanc has started
I0815 17:24:57.649875 LuaScripting.cpp:792] Starting the Lua engine
I0815 17:25:02.181265 HttpServer.cpp:824] GET /modalities
I0815 17:25:09.988786 HttpServer.cpp:824] POST /studies/page
I0815 17:25:09.988923 RestApi.cpp:235] REST method POST not allowed on: /studies/page

I can perform GETS using the REST API and AJAX, but not POSTS for some reason. The AJAX calls had preflight error with CORS previously. That isn’t showing up anymore.

With the proxy URL: https://sias.dev:8000/orthanc/app/explorer.html, that goes to the explorer. That can be accessed currently. There are 2 studies. My hip and another test hip image . It is a VPS server, so there isn’t much on there. RemoteAccess is disabled (e.g. the message about that does not show up in Explorer, so the proxy working. The other pages I am working on are:

https://sias.dev:8000/browsestudies/restapi.html (kind of a dev tool for testing calls and responses, etc.)

https://sias.dev:8000/browsestudies/index.html (pagination demo, no studies showing because the AJAX posts are blocked with 405 ERROR). The server is “Open” for the time being.

Those are ServeFolders files, so that is working also.

Not sure it is a CORS problem now. I know you have CORS set on Orthanc. Might have something to do with the URL and Port with the reverse. In the meantime, I can just keep developing from home. It works at home fine, using the same domains as on the VPS (mapped to my machine with the hosts file and proxied to localhost.

Is it just that Google changed the interface:

https://gsuiteupdates.googleblog.com/2020/05/new-google-groups-generally-available.html

Thanks.

Got it working. Had to compile the most recent version of Orthanc to be compatible with the Python Plugin. Also got some sort of compile error regarding GOOGLE_TEST. I had to install another package to get it to install. I need to populate the server with a bunch of test studies to test it all out.

Thanks.

Sorry to bother you, but I’ve got part of the pagination thing and interface working. There is a demo at:

https://sias.dev:8000/browsestudies/index.html

The pagination should be working. You can scroll the pages and change the number of rows per page.
Also downloading a dcm or iso should be working. That was kind of tricky when using just AJAX. Looks like that it working when unzipping the downloaded files. There are some things I haven’t finished yet, like building a new query based on the search form. I had that in PHP before, so I have to do that in JS now. The viewer Osimis viewer is working also. Probably leave it open for a day or 2 and then add the authentication scheme. Not sure if I can substitute the ServeFolders thing for what I have in the PHP framework, although it is nice to have that embedded with the Orthanc server. Work in progress. The pagination widget and python script probably could be improved yet. Would be nice to populate the server with a large number of test studies to do some benchmarking.

I can perform GETS using the REST API and AJAX, but not POSTS for some reason. The AJAX calls had preflight error with CORS previously. That isn’t showing up anymore.

1- The ServeFolders can only be used for GET on static resources.

2- Contrarily to your statement, CORS is not supported by Orthanc, as explained in the Orthanc Book:
https://book.orthanc-server.com/faq/nginx.html#enabling-cors