JUCE Mongoose Module - Embedded Web Server Library

I recently needed my app to run a lightweight local web server. I found This Project that wraps the Mongoose library in C++. I decided to make a basic JUCE module to wrap it! It’s very useful — especially when combined with a WebBrowserComponent. Your app can be both a web client and a web server, as well as interface with other web APIs as you would in a traditional web app.

Here is the link: https://github.com/cpenny42/juce_mongoose.

I just threw it together — didn’t bother to rewrite documentation or JUCE-ify it more. I’m planning on updating it as I go to make it better fit with the JUCE style, but it’s very powerful as it is.

Here’s a basic example:
After running this app, you could go to http://localhost:8080/hello?name=Jules to see it working.

#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
using namespace Mongoose;

class MainComponent   : public Component, public WebController
    : server (8080)
        setSize (600, 400);
    void hello (Request &request, StreamResponse &response)
        response << "Hello " << htmlEntities(request.get("name", "... what's your name ?")) << "\n";
    void setupRoutes()
        addRoute("GET", "/hello", MainComponent, hello);
    void paint (Graphics& g) override
        g.fillAll (Colours::black);
        g.setColour (Colours::white);
        g.drawText("Visit http://localhost:8080/hello to see the demo! Click to launch...",
                   0, 0, getWidth(), getHeight(), Justification::centred);
    void mouseDown (const MouseEvent& e) override
        URL url ("http://localhost:8080/hello?name=Jules");
    Server server;

To add it to your project, simply drag the “juce_mongoose” module into the Projucer next to the other modules (or put it in your custom modules location).


would it work with civetweb? mongoose is GPL2 licenced, civetweb is a liberally licensed fork before it went GPL

1 Like

We’ve used civetweb - it was good!

Cool! I think I’ll switch to that.

Wow, this sounds nuts… Im curious if the switch to the liberal licensed variant is underway?

I’ve used cpp-netlib before:


It has a liberal license and uses very modern C++. The downside is that it relies heavily on boost asio (and boost in general). However, if your project is already using boost this might be an option.