GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - WebFrame/Core: Web framework for C++ (inspired by Flask, Java Spring, Express and many others)

This repository was archived by the owner on Aug 26, 2026. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

292 Commits
292 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
benchmark
benchmark
 
 
documentation
documentation
 
 
example
example
 
 
lib
lib
 
 
reports
reports
 
 
tests
tests
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
CMakeLists.txt
CMakeLists.txt
 
 
Core.hpp.in
Core.hpp.in
 
 
Doxyfile
Doxyfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
mainpage.dox
mainpage.dox
 
 
vendor.yaml
vendor.yaml
 
 

Repository files navigation

WebFrame++ C++ Mocha
Compile & Build Benchmark & Deploy Code Quality
Issues Forks Stars License

Make your web application faster now!


Requirements

Compiler version Minimum C++ standard required
GCC, Clang, MSVC -std=c++2a or -std=c++20

Testing

Cppcheck - static code analysis

Check the static code analysis of the project here.

Performance

Check the performance check of the project here.

Code documentation

Check the Doxygen documentation of the library here.

How to use

  1. Make sure to include the library

    #include <core/core.hpp>
  2. Initiate your Web application

    webframe::core::application app;
  3. Set directories for your static files

    app.set_static(relative or absolute path/directory to the static files, web alias); 

    Ex. the files are in ./example/Sample/static and the route for them is /static:

    app.set_static("./example/Sample/static", "/static"); 

    NOTE: You can list multiple static folders

    NOTE: Relative paths depend on where you execute the executable from and not on where the source file is located.

  4. Set Inja template folder

    app.set_templates(relative or absolute path/directory to the INJA templates); 

    Ex. the Inja template files are in ./example/Sample/static/templates:

    app.set_templates("./example/Sample/static/templates");

    NOTE: You can list multiple template folders

    NOTE: Relative paths depend on where you execute the executable from and not on where the source file is located.

  5. Set up error handling

    • Set the code of the error

    • Implement the responding function using lambda that takes 1 string as parameter

      app.handle("404", [](const std::string& path) {
          return "Error 404: " + path + " was not found.";
      });
      app.handle("500", [](const std::string& reason) {
          return "Error 500: Internal server error: " + reason + ".";
      });
  6. Set up your routes

    • Set up headers and status code yourself

      app.route ("/", []() {
          return webframe::core::response (webframe::core::status_line ("1.1", "200"), {{"Content-Type", "text/html; charset=utf-8"}}, "<h1>Hello, World!</h1>");
      });
    • or let WebFrame do it for you

      app.route ("/", []() {
          return "<h1>Hello, World!</h1>";
      });
    • To render your Jinja templates use app.render(filename/file path, json with variables)

    • You can also use path/route variables

      • using predefined regex

        app.route("/{text}", [&app](const std::string& user) {
            return app.render("template.html", {{"username", user}});
        });
        Predefined Raw regex equivalent
        string [A-Za-z_%0-9.-]+
        text [A-Za-z_%0-9.-]+
        char [A-Za-z_%0-9.-]
        symbol [A-Za-z_%0-9.-]
        digit [0-9]
        number [0-9.]+
        path [A-Za-z_%0-9.-/]+
      • or using your own regex

        app.route("/{[a-z]+}", [&app](const std::string& user) {
            return app.render("template.html", {{"username", user}});
        });
  7. Make sure to run your app (async run)

    app.run(port, cores);

Advanced usage

  1. Stack multiple setups

    You can list different app setups consequently:

    app.set_static("./example/Sample/static", "/static")
        .set_templates("./example/Sample/static/templates")
        .handle("404", [](const std::string& path) {
            return "Error 404: " + path + " was not found.";
        })
        .handle("500", [](const std::string& reason) {
            return "Error 500: Internal server error: " + reason + ".";
        })
        .route ("/", []() {
            return webframe::core::response (webframe::core::status_line ("1.1", "200"), {{"Content-Type", "text/html; charset=utf-8"}}, "<h1>Hello, World!</h1>");
        });
  2. Multithreading

    • Wait until the server starts accepting requests: (sync function)

      app.wait_start(port);

      or

      app.run(port, cores).wait_start(port);
    • Wait until the server stops accepting requests: (sync function)

      app.wait_end(port);

      or

      app.run(port, cores).wait_end(port);
  3. Set up custom loggers

    • logger is the stream for standard logs from the server

    • error_logger is the stream for error messages

    • perfomancer is the stream for performance logs

      app.set_logger(ostream&)
          .set_error_logger(ostream&)
          .set_performancer(ostream&);		
  4. Force server stop

    app.request_stop(port);

    Note: port should be const char*

  5. Organize projects

    • Create set of routes

      init_routes(home)
          .route("/home", []() {
              return "This is my home page";
          });

      or if you need to use webframe::core::application functions

      webframe::core::application app;
      ...
      init_routes(home)
          .route("/home", [&app]() {
              return app.render("template.html", {{"username", user}});
          });
    • Import the set of routes to your app

      init_routes(home)
      ...
      app.extend_with(home);

      or if you want to add prefix to the set of routes

      init_routes(home)
      ...
      app.extend_with(home, "/prefix");

Check example/ for more information.

Additional info

  • Currently working on setting up CMake

Socials

LinkedIn

About

Web framework for C++ (inspired by Flask, Java Spring, Express and many others)

webframe.github.io/Core

Topics

cppcpp20cpp20-libcpp20-libraryframeworkstatic-analysisweb

Resources

Readme
GPL-3.0 license

Security policy

Security policy
Activity
Custom properties

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.