https://github.com/arsdever/expresscpp
Express server written in C++
https://github.com/arsdever/expresscpp
Last synced: 3 months ago
JSON representation
Express server written in C++
- Host: GitHub
- URL: https://github.com/arsdever/expresscpp
- Owner: arsdever
- License: mit
- Created: 2019-07-17T09:47:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-28T18:08:04.000Z (over 6 years ago)
- Last Synced: 2025-03-17T16:01:27.651Z (over 1 year ago)
- Language: C++
- Homepage:
- Size: 24.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ExpressC++
This is a library similar to ExpressJS framework. It was developed for
`C++`/`Qt` developers to make it easier to develop web applications.
# Usage
## Preparations
First of all you have to have installed [Qt 5.12.2](http://download.qt.io/official_releases/qt/5.12/5.12.2/)*
(*note that the application was developed under Qt v5.12.2, that's why the reference is to this version. It may work with the newer versions as well*)
After that download and build the project. It will require extra sources (general [interfaces](https://github.com/opensalad/interfaces) provided by [opensalad organization](https://github.com/opensalad)).
```
cd ~
git clone https://github.com/opensalad/interfaces
git clone https://github.com/arsdever/expresscpp
cd expresscpp
qmake
make
```
*__If case you download components in different folders, please have a look at the `.pro` file of `expresscpp` component to make sure that given include path is correct__*
## Example code
This is a simple code that uses the library.
``` c++
// example.cpp
#include
#include
using namespace ad::http;
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
Server express;
express.GET(QRegularExpression("/*"), [](Server::request_t &req, Server::response_t &res) {
res.setBody("Hello World");
});
express.begin();
return app.exec();
}
```
## Example `.pro` file
``` makefile
TEMPLATE = app
TARGET = application
DEFINES += QT_DEPRECATED_WARNINGS
LIBS += -L../expresscpp -lexpresscpp
INCLUDEPATH +=
SOURCES += example.cpp
QT += core
```
### Result
After all preparings, build the application using the following command from `example` containing directory
``` bash
qmake
make
```
and run it (don't miss to update `LD_LIBRARY_PATH` or simply copy the `expresscpp.so.*` files into directory)
``` bash
LD_LIBRARY_PATH= ./application
```
or
``` bash
cp /*.so* ./
./application
```
or add post-build event into `expresscpp.pro` file to copy built libraries into this path.
Now open any application to make a `HTTP GET call`. Enter uri `localhost:8008/any/path`. Do call and you will get respond
> Hello World
# Contribution
If you would like to contribute, please feel free for any feedback, code contribution, feature offer, code advice and etc. Also feel free to create an issue.
# 3rd party
As you can guess, the library is based on `Qt` library. In future it's planned to remove all `Qt` dependencies.