All Projects → shi-yan → Swiftly

shi-yan / Swiftly

Licence: other
Swiftly is an easy to use Qt/C++ web framework

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects
QMake
1090 projects

Projects that are alternatives of or similar to Swiftly

Qhttpengine
HTTP server for Qt applications
Stars: ✭ 112 (+460%)
Mutual labels:  qt, qt5, http-server
Pastebin
Modern pastebin written in golang
Stars: ✭ 111 (+455%)
Mutual labels:  web-app, web-application
EasyNotes
Apps notes for Windows, iOS and Android with P2P sync / Приложения заметок для Windows, iOS и Android, с P2P синхронизацией
Stars: ✭ 33 (+65%)
Mutual labels:  web-app, web-application
hradla
Logic network simulator that runs in your browser
Stars: ✭ 22 (+10%)
Mutual labels:  web-app, web-application
Cqtdeployer
This project is used to deploy applications written using QML, qt or other С / С++ frameworks.
Stars: ✭ 225 (+1025%)
Mutual labels:  qt, qt5
Qtusb
A cross-platform USB Module for Qt.
Stars: ✭ 245 (+1125%)
Mutual labels:  qt, qt5
software-systems-architecture
A collection of descriptions of the architecture that various systems use.
Stars: ✭ 24 (+20%)
Mutual labels:  web-app, web-application
Apk Editor Studio
Powerful yet easy to use APK editor for PC and Mac.
Stars: ✭ 197 (+885%)
Mutual labels:  qt, qt5
Polyel-Framework
⚡️ Voltis Core: A PHP framework based on Swoole from the ground up
Stars: ✭ 22 (+10%)
Mutual labels:  web-app, http-server
CometVisu
Repository for the CometVisu building automation visualisation.
Stars: ✭ 60 (+200%)
Mutual labels:  web-app, web-application
QUaServer
Qt C++ wrapper for open62541 server stack
Stars: ✭ 78 (+290%)
Mutual labels:  qt, qt5
Qml Box2d
Box2D QML plugin
Stars: ✭ 223 (+1015%)
Mutual labels:  qt, qt5
Qt Aes
Native Qt AES encryption class
Stars: ✭ 207 (+935%)
Mutual labels:  qt, qt5
Jkqtplotter
an extensive Qt5 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Stars: ✭ 246 (+1130%)
Mutual labels:  qt, qt5
Qml Creative Controls
QML controls for creative applications and creative coding
Stars: ✭ 199 (+895%)
Mutual labels:  qt, qt5
LoIDE
Web-based IDE for Logic Programming
Stars: ✭ 21 (+5%)
Mutual labels:  web-app, web-application
Raspberry-Pi-Dashboard
Web-based dashboard interface to inspect Raspberry Pi hardware and software with no extra software required.
Stars: ✭ 131 (+555%)
Mutual labels:  web-app, web-application
Browser
🌍 Cross-platform Material design web browser
Stars: ✭ 184 (+820%)
Mutual labels:  qt, qt5
Swift
Swift XMPP client and Swiften XMPP library
Stars: ✭ 190 (+850%)
Mutual labels:  qt, qt5
card matching game by ercan
A card-matching game made with Flutter.
Stars: ✭ 16 (-20%)
Mutual labels:  web-app, web-application

Swiftly

doctory badge

Swiftly is an easy to use Qt/C++ web framework I made out of boredom. As a C++ programmer, I sometimes feel left out when it comes to web development. All new languages are showing off their capabilities with some web development frameworks. But there seem to be less choices for C++ web frameworks. The goal of this project is to provide Qt programmers a way to implement web apps with their beloved framework. Swiftly emphasizes the implementation conciseness as well as speed.

Installation:

Usage:

Usually, A web site is consist of several distinct functionalities. Swiftly encourages developers to partition a web backend program into different modules based on functionality. For example, you could have a web site with a message board, a blog, a forum and a news update. These different functions or modules are called "web apps" by Swiftly's notion. When implementing a web site with Swiftly, each web app is enclosed inside a single "web app" class. The web site can have several web app classes to provide all the functionalities. Within each web app, you need to define a set of handler functions to handle requests sent to different paths. This idea should be familiar to any web backend developer. For example, you could have www.mysite.com/blog/page1, or www.mysite.com/blog/page2, these paths are handled by path handlers defined in web app classes.

Knowing these basic ideas, implementing a HelloWorld web app is as simple as defining a web app class and registering a route handler.

First, let's define a web app class "HelloWorld":

#include "WebApp.h"

class HelloWorld : public WebApp
{
    Q_OBJECT

    public:
        void registerPathHandlers();

    public slots:
        void handleHelloWorldGet(HttpRequest &,HttpResponse &);
};

This class has two functions to implement. One is a function called registerPathHandlers(). Swiftly calls this function to let the web app to register path handlers.

All you need to do here is calling addGetHandler, telling it for which path (in this case "/"), call which function to handle it (in this case "handleHelloWorldGet").

void HelloWorld::registerPathHandlers()
{
    AddGetHandler("/", handleHelloWorldGet);
}

The second function is the actual path handler which does the actual work, i.e return "Hello World" to the user.

void HelloWorld::handleHelloWorldGet(HttpRequest &request, HttpResponse &response)
{
    response << "hello world from Swiftly!\n";
}

That's it! Oh, don't forget writing a main function:

#include <QCoreApplication>
#include <QThread>
#include "Swiftly.h"
#include "HelloWorld.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    REGISTER_WEBAPP(HelloWorld);
    HttpServer::getSingleton().start(QThread::idealThreadCount(), 8080);
    return a.exec();
}

The main function is also very simple. There are two things you need to do. First, call REGISTER_WEBAPP with the name of your web app class. This will tell Swiftly that we will need to run this web app. Second, call HttpServer::getSingleton().start(QThread::idealThreadCount(), 8080). This launches the web server on port 8080. So if you go to a web browser and type http://localhost:8080, you should be able to see "hello world from Swiftly!"

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].