Skip to main content

No project description provided

Project description

Make interactive web apps using good ol’ HTML, CSS and a sprinkling of JavaScript — in Python.


HyperText Markup Lnguage

If we run this script:


from makeweb import Doc, body, h1

def generate_html():
    doc = Doc('html', lang='mr')
    with body():
    return str(doc)


We should see this output on the screen:

<!doctype html>
<html lang="mr">

(Whitespace added for clarity.)

Ha! HTML was easy, let us generate CSS from Python code.

Cascading Style Sheets


from makeweb import CSS

css = CSS()

css('body', background='white', color='#222')
css('h1', color='darkorange', margin__top='1em')


Running the above example we see…


(Whitespace added for clarity.)

Notice that the double underscore in css('h1', margin__top='1em') gets converted to hyphen in CSS as h1{margin-top:1em}. This pattern is used throughout the library for HTML and CSS attributes.

So… CSS is even easier?! How about something more ambitious?



from makeweb import JS

js = JS()

def say_hello():
    hello_box = document.getElementById("hello_box")
    hello_box.innerHTML = "Hello, World Wide Web!"


And we get a JavaScript function out!

function say_hello(){
  var hello_box;
  hello_box.innerHTML="Hello, World Wide Web!";

(Whitespace added for clarity.)

Now let us use these capabilities together!



from flask import Flask, Response
from makeweb import (
    Doc, CSS, JS,
    head, title, style, script,
    body, h1, button,

# We'll use Flask to serve, you could use any other framework
# or save as static files, or anything else
# that you wish to do with generated html.
app = Flask(__name__)
css = CSS()
js = JS()

css('*,body',   # <-- Add CSS to taste.
css('h1', color="darkblue")

@js.function  # <-- A sprinkling of JavaScript. Look ma, no braces!
def say_hello():
    hello_box = document.getElementById("hello_box")
    hello_box.innerHTML = "Hello, World Wide Web!"

def index():
    doc = Doc('html')  # <-- Generate all the HTML your app (really) needs.
    with head():
        with style():  # Embed CSS.
    with body():
        h1('...', id='hello_box')  # Set attributes.
        button('Hello', onclick="say_hello()")  # <-- hook up say_hello().
        with script():  # Embed JavaScript.
    return Response(str(doc))  # <-- Serve all the awesome your users desire!  # <-- It is time!

This app transfers ~550 bytes over the network in order to run successfully, that is including the HTTP headers overhead. You read that right, not even one kilobyte! The web technologies are quite simple and straightforward for general use, and very flexible, robust and powerful too!

You might not need (or want the baggage of) complex tooling for a small project. It could be a one time make-and-forget tool at work or a weekend hobby project, or maybe something even larger if you really like this way of working. MakeWeb can come in handy because it makes it almost trivial to build the web like it was intended, straight from your Python code.

Wait, somebody mentioned single-page-apps? How about single source-file apps that don’t download half the internet to work? 😂 Kidding, this is a very, very barebones system, and therefore you can use any existing stylesheets or JS libraries alongside MakeWeb.

Check out examples for more demos!



$ python3 -m venv makeweb
$ source makeweb/bin/activate
$ pip install makeweb[js]


$ python3 -m venv makeweb
$ source makeweb/bin/activate
$ git clone
$ cd makeweb
$ pip install -e .[examples]


$ python3 -m venv makeweb
$ source makeweb/bin/activate
$ git clone
$ cd makeweb
$ pip install -e .[dev]


$ pytest

With coverage:

$ pytest --cov=makeweb --cov-report=term

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

makeweb-0.1.0.tar.gz (7.8 kB view hashes)

Uploaded source

Built Distribution

makeweb-0.1.0-py3-none-any.whl (6.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page