• QtWebApp HTTP Server in C++


    QtWebApp HTTP Server in C++

    QtWepApp is a HTTP server library in C++, inspired by Java Servlets. For Linux, Windows, Mac OS and many other operating systems that the Qt Framework supports.

    QtWebApp contains the following components:

    • HTTP(S) Server
    • Template Engine
    • File Logger

    These components can be used independently of each other. A very small usage example:

    // The main program starts the HTTP server
    int main(int argc, char *argv[])
    {
        QCoreApplication app(argc,argv);
            
        new HttpListener(
            new QSettings("configfile.ini",QSettings::IniFormat,&app),
            new MyRequestHandler(&app),
            &app);
    
        return app.exec();
    }
    
    
    // The request handler receives and responds HTTP requests
    void MyRequestHandler::service(HttpRequest& request, HttpResponse& response)
    {
        // Get a request parameters
        QByteArray username=request.getParameter("username");
    
        // Set a response header
        response.setHeader("Content-Type", "text/html; charset=UTF-8");
    
        // Generate the HTML document
        response.write("<html><body>");
        response.write("Hello ");
        response.write(username);
        response.write("</body></html>");
    }
    

    The small memory requirement of about 2MB qualifies the web server to be used in embedded systems. For example for the Beer brewing machine of Sebastian Düll. But it's also powerful enough for larger web services.

    The logger improves disk space and performance by retaining debug messages in memory until an error occurs. No debug messages are written as long everything works fine. Changes to the configuration of the logger become active automatically without program restart.

    Source codeTutorialAPI documentation .

    The library runs with Qt version 4.7 to 6.x. In case of Qt 6 you need to install the Qt5Compat library. It contains support for a lot of 8 Bit character encodings, that Qt6 does not support anymore by default. You may use the software under the conditions of the LGPL License.

    Thanks

    The current high quality of the library is the result of the collaboration of many people. I would like to thank the helpers for testing QtWebApp extensively in a productive environment and thus contributing to the improvement.

  • 相关阅读:
    一天一道算法题---6.8--数学题
    TOJ----1037---最大独立集
    一天一道算法题---6.6---排列递推(我不会)
    一天一道算法题---6.4--中途相遇法
    一天一道算法题--6.5--数学题
    夜太美---酒不醉--人自醉
    SSH组合之Spring3整合Hibernate4(一)
    Hibernater入门
    Java微信公众平台进入开发模式
    新浪sae平台进行数据库的连接
  • 原文地址:https://www.cnblogs.com/chinasoft/p/15918770.html
Copyright © 2020-2023  润新知