Skip to main content

Autumn Framework - Build front-end in the back-end

What are we?

Autumn framework, a framework built to make front-end work as close as possible to back-end work. Our goal is not to provide a server or back-end, but a tool that makes front-end look like back-end. By making an ORM(Object Relational Mapping), we add an object-oriented way to write HTML documents and CSS styles directly from Python.

Why us?

You are not limited to us, there are Jinja2 and so many other libraries. What makes us unique is making you to look at a Python class rather than a div tag.

While our top priority is Developer Experience (DX), type safety, and over-the-top composition, we might as well note the speed and caching mechanisms:

Tests proven Autumn's speed is less than one millisecond(For simple pages), and removing the IO for visible test outputs increases the speed even more, pushing it towards/below 0.5ms. Speed is improved even further by caching tags/styles, making the load time for a static HTML page identical to a simple O(1) for a simple list lookup.

Autumn has been adding new features and fixes/docs daily, making sure that all problems are solved for you. Using metaprogramming, we've added tens of features to improve your experience, such as init autocall, decorators to disable/enable features, thread safety and error handling.

Installing

The project is available in PyPI as autumn-core, so installing it is as simple as a:

cd /path/to/new/project
python3 -m venv .venv
.venv/bin/pip install autumn-core # or .venv/Scripts/pip for windows

Then you can start using Autumn in any way you would like.

How?

The process is straight. But there are important things to consider:

  • Thread safety: While we try our best to promise thread safety, such as features like before_build, we cannot lock every read/write for classes defined outside of Autumn's hands. All classes that do not inherit from AbstractBase are NOT made to be automatically thread-safe. Your classes are up to you, so, for reads/writes, it's best to access self._lock.
  • Dynamicity: When elements are dynamic, their dynamic must be set to True. However, if any of the tags owned are dynamic, the parent will be inferred as dynamic, therefore no need to set dynamic to True. All dynamic tags completely bypass caching.
  • Building: At before_build, you can either just change the class and let the process continue, or return a string. The returned string is the final output of the build.

here is an example with HTML, another with CSS.

HTML

Instead of writing:

<div id="hello-world">Hello World!</div>

You write:

from Autumn import new

Base = new()

tag = Base.tag

class MyDiv(tag.Tag):
    def __init__(self):
        self.name = "div"
        self.closable = True
        self.identifier = "hello-world"
        self.tags = ["Hello World!"]
        # How we recommend it.
        # However, you can place spaces, tabs, and newlines, but be aware that they will be
        # Replaced with -.
        
        super().__init__()

While this seems like writing too much, it's core benefit will be seen when writing dynamic tags or when you don't know about HTML too much. Let's see an example for a dynamic tag.

import time
from Autumn import new

Base = new()


class MyText(Base.tag.Tag):
    def __init__(self, classes: list[str]):
        self.name = "p"
        self.closable = True
        self.classes = classes
        self.dynamic = True
        
        super().__init__()

    def before_build(self, **_kwargs): # Recommended.
        self.tags.append(time.time())

This will produce a well behaving Paragraph with dynamic elements.

CSS

Well, this is straight forward.

div.any-div#my-div-used-for-footer {color: #000000;}

will simply turn into:

from typing import Any
from Autumn import new

Base = new()

class MyStyle(Base.style.Style):
    
    def __init__(self):
        self.name = Base.name.Name("div", Base.name.Identifier("my-div-used-for-footer"),
                                   [Base.name.Class("any-div")])
        self.styles = [
            "color: #000000;"
        ]
        
        super().__init__()

This will also become valuable when writing dynamic CSS or when you simply don't know CSS. Let's see an example for that too.

from typing import Any
from Autumn import new

Base = new()

class MyStyle(Base.style.Style):
    
    def __init__(self):
        self.name = Base.name.Name("div", Base.name.Identifier("my-div-used-for-footer"),
                                   [Base.name.Class("any-div")])
        self.styles = [
            "color: #000000;"
        ]
        
        self.dynamic = True
        
        super().__init__()

    def before_build(self, **kwargs):
        if "style" in kwargs:
            self.styles.append(kwargs["style"])
    

A note on Thread safety

Thread safety is one of the most important parts to remember, every public and private method is automatically thread-safe if it inherits from AbstractBase. Well, excluding getattribute, setattr, every public/private method is thread-safe, unless it's a protected method. We do not lock protected methods, as they are (mostly, by convenience) used by the public/private methods themselves.

When to prefer Autumn

As said, there are many other great options, but Autumn's unique philosophy and traits are one of the reasons people use Autumn instead of Jinja2 or React.

Tools Autumn Jinja2 React etc(e.g., Dominate)...
Paradigm Frontend Framework Server Side Templating Language Client-Side UI Library Python HTML Generator
Core Philosophy A framework that treats HTML tags and CSS Styles as Python Objects, Making frontend works as intuitive as ORM work. A text-based templating engine that mixes HTML with special placeholders and logic. A declarative, component-based JavaScript library for building interactive user interfaces. A Python library that uses a DOM API to create HTML documents in pure Python, eliminating the need for a separate template language.
Core Abstraction Python Classes/Objects Templates Components DOM API
Environment Server Server Client Server
Primary Use case Generating HTML on the server-side, commonly used with frameworks like Flask and Django. Building complex, interactive single-page applications (SPAs) with dynamic user interfaces. Creating and manipulating HTML documents programmatically in Python scripts, often for tasks like report generation. Building front-end interfaces directly from Python, with a focus on developer experience and type safety.
Strengths Object-Oriented DX: Provides a unique, class-based approach that may feel natural to back-end developers.
Type Safety: Type safe, a benefit over traditional templating. Performance: High speed (less than one millisecond for simple pages) with effective caching mechanisms.
Mature & Widely Adopted: The standard for Python web frameworks.
Powerful Features: Template inheritance, auto-escaping for security, sandboxed execution, and fast just-in-time compilation.
Interactive & Dynamic: Unmatched for building highly responsive user interfaces.
Ecosystem: Massive community, rich ecosystem of libraries, and strong corporate backing (Meta).
Reusability: Components are highly composable and reusable.
Pythonic & Simple: No need to learn a new templating language; uses pure Python.
Concise: Allows for very concise HTML generation.
Great for Scripts: Perfect for generating HTML in scripts or automated tasks.
Weaknesses New & Unproven: A very new framework with a small community and limited real-world usage.
Immature Ecosystem: Lacks the extensive ecosystem and tooling of Jinja2 or React.
Context Switching: Requires mixing Python logic with HTML in a separate syntax.
Server-Side Only: Cannot handle client-side interactivity on its own; requires JavaScript.
Complexity: Steeper learning curve, requires understanding of JSX, state, and props.
Client-Side Heavy: Relies heavily on client-side rendering, which can impact SEO and initial load time without frameworks like Next.js.
Less Interactive: Not a framework for building web apps; purely for generating HTML structures.
Niche Use: Best for specific tasks like report generation, not full-scale web development.

Autumn Essential Extensions

Autumn has a few extensions to offer. While not many, the ones currently available are:

New extensions will be added eventually, as this is not all we have to offer. Among the few extensions, these are the only ones public for now.

Our future goals

Our future goals (currently) can be listed as:

  1. Out of the box experience.
  2. A stable and mature ecosystem.
  3. Complete support for HTML/CSS, etc...

Metadata

Release files for autumn-core 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autumn-core 1.4.0
File Size Uploaded Provenance
autumn_core-1.4.0.tar.gz 27.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for autumn-core 1.4.0
File Interpreter ABI Platform
autumn_core-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 76.6 kB

Release files / autumn_core-1.4.0.tar.gz

Download URL autumn_core-1.4.0.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b06cd1dcc6736088b2e51ec4119e32cfcb01c45b2cc15a25f892dede3d860fbd
BLAKE2b-256 checksum
How to use checksums
a207e695542835516e2496d5c16d3abba0e2fb0ba4b4d2feafe5a2848fb15869
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / autumn_core-1.4.0-py3-none-any.whl

Download URL autumn_core-1.4.0-py3-none-any.whl
Size 49.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
904538a6d6d759fc6b8728a78d400e30f80343780d781113091516989c4a52df
BLAKE2b-256 checksum
How to use checksums
06a547603213aa1870f0d3af7e9e6c28186b0b24799dbb818eac2c3882a0d8f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for autumn-core 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page