Giter Site home page Giter Site logo

bredamatt / cppweb Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 2.85 MB

A way to host your own C++ written webserver from a docker container

Dockerfile 0.20% C++ 93.60% CMake 1.76% C 2.46% Makefile 1.38% HTML 0.43% JavaScript 0.16% CSS 0.01%
cplusplus docker webserver website server abstraction

cppweb's Introduction

CppWeb

This is a repository used as work in progress for my company's website. It is created with security and performance in mind, as the C++ server is running inside a Docker container.

Dependencies

A range of tools are used to build the website:

Additionally, the service may be deployed to Heroku easily using Heroku's Container Registry & Runtime Service.

For more information on that service, see: https://devcenter.heroku.com/articles/container-registry-and-runtime

Structure

The structure of the repository is as follows:

--CppWeb
    |
    |---box (the initial container without MongoDB)
    |
    |
    |---hello_crow (main.cpp, CMakeLists.txt and Dockerfile)   <<---- main folder
    |       |
    |       |
    |       |----bbox (used to build MongoDB C and C++ Drivers for the container, has a Dockerfile)
    |       |
    |       |----build (executable folder)
    |       |
    |       |----public (.html files / views)
    |               |
    |               |----images  (.jpeg files)
    |               |
    |               |----scripts (.js scripts)
    |               |
    |               |----styles (.css files)
    |
    |
    |---root (crow_all_.h, and other .h files here)

Instructions

Usage

To test this simply execute the following commands from your terminal:

$ git clone

Navigate to the /hello_crow dir and execute (remember the . ):

$ docker build --rm --squash --no-cache -t hello_crow:latest .

Follow the instructions on https://devcenter.heroku.com/articles/container-registry-and-runtime to deploy your container to Heroku.

Navigate to localhost:8080 in Chrome, then use the route handlers as specified in main.cpp to test the service. You should be able to:

  1. View contacts in JSON
  2. View contacts in formatted JSON (AJAX Bulma)
  3. Enter a chat room
  4. Query a specific contact
  5. Adding doubles, integers, or strings
  6. Accessing an about page

Try to look these up in main.cpp

Using Crow

In this case, we are writing the server in C++ for high performance. Here, we are using the Crow microframework. According to the benchmark, crow can handle up to 300,000 requests per second. It also contains both Middleware and Websocket support, which is neat for building more complex services.

Crow is very simple to use, just copy amalgamate/crow_all.hand use it in your project by including it in your C++ webserver with:

#include "crow_all.h"

For more information, see: https://github.com/ipkn/crow

cppweb's People

Contributors

bredamatt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.