DICOM: Analysis of Web Server, Mongoose, dicomorthanc in Orthanc

Source: Internet
Author: User

DICOM: Analysis of Web Server, Mongoose, dicomorthanc in Orthanc
Background:

This article introduces the installation and use of deconstruct PACS Orthanc, as well as analysis of related plug-ins, SQLite databases and other main modules. This article briefly introduces the Web Server embedded in Orthanc, mongoose. Based on Mongoose, a lightweight Web Server, Orthanc can effectively integrate RESTful APIs with traditional DICOM services, which is also the key to implementing distributed PACS. The blog post first gave Mongoose installation and simple embedded programming with C/C ++, giving you a preliminary understanding of Mongoose and further analysis.

Mongoose Web Server:

Mongoose Web Server official website address is http://cesanta.com/mongoose.shtml, open source project on googlecode( http://code.google.com/p/mongoose/), currently domestic can only open with VPN. Mongoose stands for the name of an animal. Here Mongoose refers to a Web server, which can be easily embedded into an existing application by providing a web interface. The execution of Mongoose Web Server is self-satisfied and independent from any other services. You can copy it to any directory at will. It will start the web service and use the current directory as the main directory and the port number is 8080. Of course, these configuration options can be set through the configuration file mongoose. conf.

Download and install:

To quickly experience Mongoose, you can download the free version of the installation package on the official website and double-click it. The official website contains the installation packages corresponding to Windows, MacOS, and Linux systems, as shown in:



As an excellent open-source project, we naturally hope to download it to the source code. For Mongoose, the source code is very small, and only the mongoose. h and mongoose. c files are available. Its source code is hosted on Github at Ghost. In the Mongoose code repository, README. the md file provides a download link DownLoads, which is slightly different from the process of downloading the running package on the official website. After selecting the corresponding version, you need to enter the contact method to obtain the download link. What is amazing is that the format of 163, 126, and QQ mailboxes in the email address is incorrect. It seems that only foreign mailboxes such as GMail and Hotmail can be used. Considering the stability of GMail services in China, I chose Hotmail directly.



After entering the correct email address, you will receive an official email. Open the link to download the Mongoose source code package. You can Clone it from Github.

According to the previous use process for open-source projects, the next step should be local compilation. Because the Mongoose source code is only mongoose. h and mongoose. c, and self-contained. Here we will not separately introduce how to compile these two source code files. For people with programming experience, so easy, of course, if you use a Linux system, you can refer to the Mongoose source code analysis in this blog post: Introduction and Installation.

Compilation attempt:

Create a C ++ console project locally and directly embed Mongoose in it. The reference here is the Embed. md under the docs folder in the source code package.


Create the MongooseEmbbed project locally. To create a clear mongoose_source folder, set the mongoose. h and mongoose. copy the c file to it and open MongooseEmbbed. sln project, right-click to add "existing project", and select mongoose. h and mongoose. add file c to the header file and source file, as shown in:


Next, enter the sample code in the project file MongooseEmbbed. cpp according to the description of the Embed. md file. The specific code is as follows (directly copy the code from 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 ;}

When you press F6 to start the project compilation, an error occurs. Let's take a look at how to solve the problem.

Compilation errors and solutions:


Error 1:

First encountered errors such,



It can be seen from the error prompt that this should be an error in the pre-compilation header. The simplest solution to this problem is to cancel the pre-compilation in the pre-compilation header of the Project attribute, of course, the Compilation Time will increase a lot after the pre-compilation is canceled for a large project. For the analysis of this problem, you can refer to the pre-compilation header file from the early version of the compiler, or use it (or vice versa) in C when the pre-compiled header is C ++ ). Since the project is very small, I directly use the method of disabling pre-compilation, such as the operation:




After the modification, a new error occurs when F6 starts compilation. The specific error is as follows.

Error 2:



Baidu searched for the solution to the problem._ CRT_NONSTDC_NO_DEPRECATESo I tried to add # define _ CRT_NONSTDC_NO_DEPRECATE or # define _ CRT_NONSTDC_NO_DEPRECATE 1 in the Code project, whether in # include "stdafx. h "the error still occurs before or after the code. Later, I thought that the definition of the pre-processor should be added under the pre-processor project of the Project attribute in VS. After trying, the compilation of the MongooseEmbeed. sln project can be completed smoothly.




Run the test:

Next, let's start the MongooseEmbbed. sln project and test it. Enter http: // localhost: 8080 in the browser. Here, 8080 is the listening port number of the Mongoose Web Server we set in the main project file. The test result is as follows:




The file list in the directory where the MongooseEmbbed project is located is displayed on the right. By default, the Mongoose Web Server uses the project directory as the Home Directory of the Web Server. Previously, in the series of blog posts about web pacs, we mentioned that Web server has a simple index file, which is usually called index.html (of course, you can also set it freely in the configuration options ). Finally, let us copy the mongoose-5.5 \ mongoose-5.5 \ examples \ restful_api \ index.html to the main directory of the project, and then start the local project, this time we see Mongoose Web serverautomatically built the main directory index.html document, the specific running result is as follows:




The Mongoose Web Server settings are in MongooseEmbbed. the sln Code only shows how to set the main directory of the Web service and the listening port. The setting of index files is not described, but. in the c source code, you can see the order of the default index file of mongoose, that isIndex.html,index.htm,index.shtml, index. cgi, index. php, And other default configurations are as follows.

static const char *static_config_options[] = {  "access_control_list", NULL,#ifndef MONGOOSE_NO_FILESYSTEM  "access_log_file", NULL,#ifndef MONGOOSE_NO_AUTH  "auth_domain", "mydomain.com",#endif#ifndef MONGOOSE_NO_CGI  "cgi_interpreter", NULL,  "cgi_pattern", DEFAULT_CGI_PATTERN,#endif  "dav_auth_file", NULL,  "document_root",  NULL,#ifndef MONGOOSE_NO_DIRECTORY_LISTING  "enable_directory_listing", "yes",#endif#endif  "enable_proxy", NULL,  "extra_mime_types", NULL,#if !defined(MONGOOSE_NO_FILESYSTEM) && !defined(MONGOOSE_NO_AUTH)  "global_auth_file", NULL,#endif#ifndef MONGOOSE_NO_FILESYSTEM  "hide_files_patterns", NULL,  "hexdump_file", NULL,  "index_files","index.html,index.htm,index.shtml,index.cgi,index.php",#endif  "listening_port", NULL,#ifndef _WIN32  "run_as_user", NULL,#endif#ifndef MONGOOSE_NO_SSI  "ssi_pattern", "**.shtml$|**.shtm$",#endif  "url_rewrites", NULL,  NULL};


So far, a brief introduction to Mongoose Web Server Installation and local embedding has been completed. From the code above, we can see that Mongoose is similar to other Web servers such as Apache, we can also configure the Mongoose Web Server as needed. We will introduce the source code analysis and configuration of Mongoose in subsequent blog posts, so stay tuned.




By zssure@163.com

Time:



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.