Giter Site home page Giter Site logo

fastcgi's Introduction

Fastcgi

A simple C++ implementation of fastcgi protocol which enables you to write your web application logic in C++.

Usage

Implementing a fastcgi application is easy, one should first create a class that inherits responder, then server class that accepts incoming requests.

#include "../server.h"
#include "../responder.h"
#include <string.h>

class helloWorld : public fastcgi::responder
{
public:
    void respond()
    {
        const char *test =
                "Content-Type: text/html\n"
                        "Content-Length: 115\n"
                        "\n"
                        "<!DOCTYPE html>\n"
                        "<html>\n"
                        "\t<head>\n"
                        "\t\t<title>Wellcome!</title>\n"
                        "\t</head>\n"
                        "\t<body>\n"
                        "\t\t<h1>Hello World!</h1>\n"
                        "\t</body>\n"
                        "</html>";
        writeBody(test, strlen(test));
    };
};

int main(int argc, char * argv[])
{
    fastcgi::server app(new helloWorld);
    app.accept();
    return 0;
}

You must run the application yourself and point the web sever to which port server is listening (default is 8080).

Simple Nginx configuration that should work with fastcgi:

server {
    listen 80;
    server_name localhost;
    
    location / {
        include fastcgi_params;
        fastcgi_pass localhost:8080;
    }
}

Building

The build system is CMake and there should be no problem building on Linux. MS Windows is not supported yet.

First clone:

$ git clone https://github.com/rabbanian/fastcgi.git

Then make a build directory:

$ mkdir fastcgi/build/
$ cd fastcgi/build/

Run CMake:

$ cmake ..

And Make:

$ make

fastcgi's People

Contributors

rabbanian avatar

Stargazers

Milad Varvaei avatar   avatar

Watchers

 avatar

Forkers

chujiangke

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.