Giter Club home page Giter Club logo

bogart's Introduction

Bogart

Bogart is a (mostly facetious) response to the Sinatra project. The primary difference between the two projects is that Bogart is written in C, with the purpose of making it quick and easy to write little web services in C.

This code has every security flaw you imagine, tons of memory leaks, and when I wrote it I may have been awake for much longer than one should be when writing C.

A secondary reason for its existence was to give me an excuse to play with Apple's anonymous function extension to C. So, given that, it will only compile on OS X.

It uses libevent, so you'll need that.

If I get around to finishing it, it'll also support simple little models using Redis.

Example

#include <stdio.h>
#include "bogart.h"

Bogart {
    UseRedis;
    
    get("/hello") {
        body("<h1>Hello, World!</h1>");
    };

    get("/create") {
        redisCommand(_redisFd, "HSET User:%s %s %s", params("id"), "name", params("name"));
        body("User created.");
    };

    get("/show") {
        redisReply * reply = redisCommand(_redisFd, "HGET User:%s %s", params("id"), "name");
        view("index.cml", map("name", reply->reply));
    };

    Start(11000)
}

Pretty stupid simple.

You might notice that "index.cml" bit in the last route. I rolled a crappy little template system into it. You pass view a filename and a mapping of keys to strings.

So, check it out if you're curious how it's done... But don't use it for anything. Ever.

Tyler McMullen

bogart's People

Watchers

 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.