Skip to main content

Dynamic Web Application (DWA) framework written with Tornado.

Project description

Dynamic Web Application (DWA)

version license pyversions
donate powered made

Dynamic Web Application (DWA) framework written with Tornado.

Hierarchy

dwa

Example

python

./pages/init.py

from . import root
from . import common

./pages/common.py

from dwa import *


class static_file_page(handlers.StaticFileHandler):
    def validate_absolute_path(self, root, absolute_path):
        return super().validate_absolute_path(root, absolute_path)

    def set_extra_headers(self, path):
        self.set_header('Cache-Control', 'must-revalidate, max-age=0')

./pages/root.py

from dwa import *
from . import common


server_name = "root"


class root_html(handlers.HTML):
    server = server_name


class index_page(root_html):
    file_name = "index"


def get_root_settings(app_root):
    app_root = os.path.join(app_root, server_name)
    return (
        server_name,
        [
            (r"/", index_page),
            (r"/((?:img|js|css|common)/.*)", common.static_file_page, {"path": app_root}),
        ]
    )

./app.py

from dwa import *
import pages


def app_settings_template(app_root: str, domain: str, port: int, cookies_expires_day: float) -> dict:
    settings = {}
    db = "db/db.db"
    settings["cookie_secret"] = open(os.path.join(app_root, "cookie_secret.txt"), "rb").read()
    settings["port"] = port
    settings["db"] = db
    settings["domain"] = domain
    settings["cookies_expires_day"] = cookies_expires_day
    servers = [
        pages.root.get_root_settings(app_root),
    ]
    settings["servers"] = {k: v for k, v in servers}
    return settings


def app_settings(app_root: str) -> dict:
    return app_settings_template(app_root, "your.domain.com", 8888, 1)

./test.py

import dwa

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

dwa-0.0.9.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

dwa-0.0.9-py3-none-any.whl (20.0 kB 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