DICOM: Anatomy of Web Server in Orthanc, Mongoose

Source: Internet
Author: User

background:

The Dicom column introduces the installation and use of the deconstructed PACs (distributed PACs) Orthanc, as well as the analysis of the main modules such as plug-ins and SQLite databases, and introduces the Web Server,mongoose embedded in Orthanc. Relying on Mongoose, this lightweight web Server,orthanc is a good implementation of the RESTful API and traditional DICOM service integration, which is the key to achieve distributed PACs. Blog post first give the installation of mongoose and simple and C + + embedded programming, so that we have a preliminary understanding of mongoose, follow-up and further analysis.

Mongoose Web Server:

Mongoose Web Server's official address is http://cesanta.com/mongoose.shtml, and the Open source project is hosted on Googlecode (http://code.google.com/p/mongoose/ ), the current domestic only use VPN open. Mongoose English original meaning is the name of an animal, here Mongoose refers to a Web server, by providing a web interface to it, can be easily embedded into existing applications. Mongoose Web Server execution is self-fulfilling and does not depend on any other services. It can be arbitrarily copied to any directory, it will start the Web service and will be the current directory as the home directory, the port number is 8080. Of course, these configuration options can be set through the configuration file mongoose.conf.

Download and install:

Want to quickly experience the mongoose, can go to the official website directly download the free version of the installation package double-click to open, the official website has a Windows, MacOS, Linux system corresponding to the installation package, as shown in:


As a good open source project, we naturally hope to download to the source code, for mongoose, the source is very few, only mongoose.h and mongoose.c two files. Its source code on GitHub's hosting address is Https://github.com/cesanta/mongoose, From the code warehouse can be seen in the official source package in addition to contain mongoose.h and mongoose.c source files, but also the description of the document and test cases, here we download the complete Mongoose source package, easy to follow the learning and use. In the Mongoose Code warehouse readme.md file gives a download link downloads, where the link and the official website to carry the package of the flow slightly different, select the corresponding version after we need to enter the contact method to obtain the download link. More wonderful is the email address entered 163, 126 and QQ mailbox will prompt format error, it appears that only use foreign mailboxes, such as Gmail, Hotmail. Given the stability of Gmail's current domestic service, I opted to use Hotmail.


After entering the correct email address, you will receive an official e-mail and open the link to download the Mongoose source package. You can also clone directly from GitHub.

Following the previous use of open source projects, the next step should be local compilation. Since Mongoose source only mongoose.h and mongoose.c, and self-contained, here is not alone how to compile these two source files, for people with programming experience so easy, Of course, if you use a Linux system can also refer to the blog Mongoose Source analysis: Introduction and installation.

Compile attempt:

Create a C + + Console project locally and start embedding mongoose directly in it. The references here are embed.md under the Docs folder in the source package.

Build mongooseembbed project locally, create Mongoose_source folder for clear structure, copy mongoose.h and mongoose.c files to it, open MongooseEmbbed.sln project, right-click Add "Existing Project , add the mongoose.h and mongoose.c files to the header file and the source file, respectively, as shown in:

Next follow the instructions in the Embed.md file, enter the sample code in the project file MongooseEmbbed.cpp file as follows (copied directly from the EMBED.MD),

MongooseEmbbed.cpp: Defines the entry point of the console application. #include "stdafx.h" #include "mongoose.h" int _tmain (int argc, _tchar* argv[]) {struct Mg_server *server= mg_create_ Server (null,null); mg_set_option (server, "Document_root", "."); Mg_set_option (server, "Listening_port", "8080"); for (;;) {mg_poll_server (server,1000);} Mg_destroy_server (&server); return 0;}

Press F6 to start the project compile, unexpectedly error, then let us see how to resolve the error.

compilation errors and solutions:


Error 1:

The first errors encountered are as follows,


As you can see from the error message, this should be a precompiled header error, the simplest solution is to de-precompile in the "Precompiled header" of the project properties, and of course the compilation time will increase for large projects after the precompilation is canceled. For the analysis of this problem, you can refer to the precompiled header file from an earlier version of the compiler, or the precompiled header is C + + and use it in C (or vice versa). In this case, because the project is very small, directly using the method of shutdown precompilation, such as Operation:


After the modification is complete, the F6 starts the compilation, and a new error appears, with the following specific error.

Error 2:


Baidu Search, the solution to this problem is to add _crt_nonstdc_no_deprecate predefined, so initially tried to directly add #define in code engineering _crt_nonstdc_no_deprecate or #define _CRT_NONSTDC_NO_DEPRECATE 1, the error still occurs either before or after the #include "stdafx.h" code. And then think about it. The definition of the preprocessor in VS should be added under the project properties of the preprocessor project, such as the attempt to successfully complete the compilation of the MongooseEmbeed.sln project.


To run the test:

Next, let's start the MongooseEmbbed.sln project and actually test it. In the browser, type:http://localhost:8080, where 8080 is the listening port number of the Mongoose Web server that we set up in the project master file, the test results are as follows:


On the right is the list of files in the directory where the Mongooseembbed project is located, and Mongoose Web server defaults to the directory where the project resides as the home directory of the Web server. As mentioned earlier in the series on Web PACs, Web server has a default index file, often called index.html (which can be set freely in configuration options). In the Mongoose source package examples folder for us to prepare a variety of index.html, let us will mongoose-5.5\mongoose-5.5\examples\restful_api\ index.html Copy to the project Master directory, once again to start the local project, this time we see Mongoose Web server automatically loaded the home directory index.html document, the results of the operation such as:


At this point, a brief introduction to the installation and local embedding of Mongoose Web server is complete, similar to other Web servers like Apache, and we can configure Mongoose Web server as we wish. For Mongoose's source analysis and configuration after the following blog post, please look forward to.




[email protected]

Date: 2015-01-25



DICOM: Profiling Web Server in Orthanc, Mongoose

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.