Giter Site home page Giter Site logo

msrd0 / qtwebapp Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 17.0 596 KB

QtWepApp is a HTTP server library in C++, inspired by Java Servlets. Forked from: http://stefanfrings.de/qtwebapp/index-en.html

License: GNU Lesser General Public License v3.0

HTML 0.25% Smarty 0.25% C++ 93.83% C 0.41% CMake 5.00% Shell 0.26%
cpp http http-server qt qt5 qt6 qtwebapp webserver

qtwebapp's Introduction

THIS PROJECT IS NO LONGER MAINTAINED

QtWebApp Build License

This library was forked from http://stefanfrings.de/qtwebapp/index-en.html

QtWebApp is a library to develop server-side web applications in C++. It depends on Qt5, minimum required version is 5.5.

The library comes with 3 components:

  • HttpServer
  • TemplateEngine
  • Logging

Usage

This short example demonstrates how to use the library:

class DefaultRequestHandler : public HttpRequestHandler
{
public:
	void service(HttpRequest &request, HttpResponse &response);
}

void DefaultRequestHandler::service(HttpRequest &request, HttpResponse &response)
{
	response.write("<html><body><h1>" + request.getPath() + "</h1></body></html>");
}

int main(int argc, char **argv)
{
	QCoreApplication app(argc, argv);
	
	QSettings *config = new QSettings;
	// ...
	
	new HttpListener(config, new DefaultRequestHandler);
	return app.exec();
}

You can the compile it using cmake, like this:

# ...
find_package(QtWebApp REQUIRED COMPONENTS HttpServer)
add_executable(thinkofabettername main.cpp)
target_link_libraries(thinkofabettername ${QtWebApp_LIBRARIES})
# ...

Build

QtWebApp uses CMake as the build system. To compile, simply run:

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4
sudo make install

qtwebapp's People

Contributors

dependabot[bot] avatar gladhorn avatar mortengunnufsen avatar msrd0 avatar tereius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qtwebapp's Issues

How to support gui thread.

When I handle a new connection,I want use qtwebkit to get a page and send back in this connection,but got the error:

ASSERT failure in QWidget: "Widgets must be created in the GUI thread.", file kernel\qwidget.cpp, line 1133

Fix GitHub Actions on Windows

The CI fails on Windows with some weird linker error. I have no experience whatsoever with Windows, so if someone knows how to fix this, please tell me / open a PR!

Is it possible to send button click signal to qt side without forms?

Hello,

I want to implement multiple buttons on one page for ex. to control blind rollers, by pressing a button the blind goes up by few centimeters, by press and hold it continously goes up etc.
Is it possible to do this mechanic using this library? I only saw examples by sending data using forms and post/get method but can you use javascript to send data directly to c++? or plain input type button without the need of form?
Thanks for response :)

StaticFileController

QtWebApp/httpserver/staticfilecontroller.cpp
the code here:

if (!cfg.fileName.isEmpty() && !(docroot.startsWith(":/") || !docroot.startsWith("qrc://"))) {
	// Convert relative path to absolute, based on the directory of the config file.
	if (QDir::isRelativePath(docroot)) {
		QFileInfo configFile(cfg.fileName);
		docroot = QFileInfo(configFile.absolutePath(), docroot).absoluteFilePath();
	}
}`

The first judgment condition is wrong. Suppose my [docroot] is "../location/staticfiles", it returns false.

using any SQL database in project

dear friend
despite this is newest fork of QtWebApp, i wonder if you can help.
in short sentence, exactly where should i create a database connection in project?
Qt does not allow to use database connection that is created in a controller to be executed in the HttpRequestHandler::service()
even i tried to have db in the HttpRequestHandler itself. but again db queries don't exec inside service() method and all ways throws this error:
QSqlDatabasePrivate::database: requested database does not belong to the calling thread.
best regards
Hameed Abbasi

Qt 6 build relies on qt5compat

Currently QtWebApp built with Qt 6 needs the compatibility module. Over time it would be great to get rid of the dependency. The question is how. The compatibility is needed for QTextCodec which is used by the template engine. I'm unsure whether it would be good enough to drop the codec conversion API and require UTF-8 (I think this sounds sensible) or how important it is to keep compatibility here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.