Skip to main content

Social web framework

Project description

Understory

Social web framework

Create a web app

You should use Poetry.

poetry init
poetry add understory

Create the following file structure:

example
├── __init__.py
├── static
│   └── screen.css
└── templates
    ├── __init__.py
    └── index.html

example/__init__.py

import web
from understory import indieauth

app = web.application(__name__, mounts=[indieauth.client.app])


@app.control("")
class Landing:
    def get(self):
        return app.view.index(web.tx.user)

example/static/screen.css

p.greeting { color: #f00; font-size: 5em; }

example/templates/__init__.py

import random

from understory.indieauth import web_sign_in

__all__ = ["random", "web_sign_in_form"]

example/templates/index.html

$def with (user, greeting)

$if user.session:
    $ greeting = random.choice(["hello", "hi", "howdy"])
    <p class=greeting>$greeting $user.name ($user.url)</p>
$else:
    $:web_sign_in_form()

Serve it locally

poetry run web serve example

The server will automatically reload on changes to the source code.

Host it in the cloud

poetry run web host example

URL parsing

Defaults to safe-mode and raises DangerousURL eagerly. Up-to-date public suffix and HSTS support.

>>> url = skutterbug.uri("example.cnpy.gdn/foo/bar?id=38")
>>> url.host
'example.cnpy.gdn'
>>> url.suffix
'cnpy.gdn'
>>> url.is_hsts()
True

Cache

uses SQLite

>>> cache = skutterbug.cache()
>>> cache["indieweb.org/note"].entry["summary"]
'A note is a post that is typically short unstructured* plain text, written & posted quickly, that has its own permalink page.'
>>> cache["indieweb.org/note"].entry["summary"]  # served from cache
'A note is a post that is typically short unstructured* plain text, written & posted quickly, that has its own permalink page.'

Microformat parsing

Parse mf2 from HTML. Analyze vocabularies for stability/interoperability.

Browser

uses Firefox via Selenium

>>> # browser = skutterbug.Firefox()
>>> # browser.go("en.wikipedia.org/wiki/Pasta")
>>> # browser.shot("wikipedia-pasta.png")

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

understory-0.0.363.tar.gz (10.3 MB view hashes)

Uploaded Source

Built Distribution

understory-0.0.363-py3-none-any.whl (10.8 MB view hashes)

Uploaded Python 3

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