Skip to content

Commit

Permalink
Merge pull request #167 from vkottler/dev/3.5.1
Browse files Browse the repository at this point in the history
3.5.1 - Use new svgen Html element
  • Loading branch information
vkottler authored Feb 19, 2024
2 parents db589b0 + 684983a commit 84b7954
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- run: |
mk python-release owner=vkottler \
repo=runtimepy version=3.5.0
repo=runtimepy version=3.5.1
if: |
matrix.python-version == '3.11'
&& matrix.system == 'ubuntu-latest'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
=====================================
generator=datazen
version=3.1.4
hash=487a8680ee41c28e805d93708ad0973f
hash=0d3102d72d813144bd511aadcc56bc20
=====================================
-->

# runtimepy ([3.5.0](https://pypi.org/project/runtimepy/))
# runtimepy ([3.5.1](https://pypi.org/project/runtimepy/))

[![python](https://img.shields.io/pypi/pyversions/runtimepy.svg)](https://pypi.org/project/runtimepy/)
![Build Status](https://github.com/vkottler/runtimepy/workflows/Python%20Package/badge.svg)
Expand Down
2 changes: 1 addition & 1 deletion local/configs/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ entry: {{entry}}

requirements:
- vcorelib>=3.2.0
- svgen
- svgen>=0.5.0
- websockets
- "windows-curses; sys_platform == 'win32' and python_version < '3.12'"

Expand Down
2 changes: 1 addition & 1 deletion local/variables/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
major: 3
minor: 5
patch: 0
patch: 1
entry: runtimepy
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__"

[project]
name = "runtimepy"
version = "3.5.0"
version = "3.5.1"
description = "A framework for implementing Python services."
readme = "README.md"
requires-python = ">=3.11"
Expand Down
4 changes: 2 additions & 2 deletions runtimepy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.4
# hash=4b3acb30b6d5eb59ef87ed685da69bb3
# hash=186dece058b8aed58af9d04779e0965a
# =====================================

"""
Expand All @@ -10,7 +10,7 @@

DESCRIPTION = "A framework for implementing Python services."
PKG_NAME = "runtimepy"
VERSION = "3.5.0"
VERSION = "3.5.1"

# runtimepy-specific content.
METRICS_NAME = "metrics"
46 changes: 7 additions & 39 deletions runtimepy/net/server/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from typing import Awaitable, Callable, Optional, TextIO

# third-party
from svgen.attribute import attributes
from svgen.element import Element
from svgen.element.html import Html
from vcorelib import DEFAULT_ENCODING

# internal
Expand All @@ -16,49 +16,24 @@
from runtimepy.net.tcp.http import HttpConnection

HtmlApp = Callable[
[Element, Element, RequestHeader, ResponseHeader, Optional[bytes]],
Awaitable[None],
[Html, RequestHeader, ResponseHeader, Optional[bytes]], Awaitable[None]
]
HtmlApps = dict[str, HtmlApp]


async def default_html_app(
head: Element,
body: Element,
document: Html,
request: RequestHeader,
response: ResponseHeader,
request_data: Optional[bytes],
) -> None:
"""A simple 'Hello, world!' application."""

del head
del request
del response
del request_data

body.children.append(Element(tag="div", text="Hello, world!"))


# A default 'head' section to use in the HTML document.
HEAD = Element(
tag="head",
children=[
Element(
tag="meta",
attrib=attributes({"charset": DEFAULT_ENCODING}),
),
Element(
tag="meta",
attrib=attributes(
{
"name": "viewport",
"content": "width=device-width, initial-scale=1",
}
),
),
Element(tag="title", text=HttpConnection.identity),
],
)
document.body.children.append(Element(tag="div", text="Hello, world!"))


async def html_handler(
Expand All @@ -74,18 +49,11 @@ async def html_handler(
# Set response headers.
response["Content-Type"] = f"text/html; charset={DEFAULT_ENCODING}"

# Create a copy at some point?
head = HEAD

body = Element(tag="body")

# Create the application.
document = Html(HttpConnection.identity)
await apps.get(request.target.path, default_app)(
head, body, request, response, request_data
document, request, response, request_data
)

stream.write("<!DOCTYPE html>\n")
html = Element(
tag="html", attrib=attributes({"lang": "en"}), children=[head, body]
)
html.encode(stream)
document.encode(stream)
2 changes: 1 addition & 1 deletion runtimepy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vcorelib>=3.2.0
svgen
svgen>=0.5.0
websockets
windows-curses; sys_platform == 'win32' and python_version < '3.12'

0 comments on commit 84b7954

Please sign in to comment.