PyWSGIRef 1.1.11__tar.gz → 1.1.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pywsgiref-1.1.11/src/PyWSGIRef.egg-info → pywsgiref-1.1.13}/PKG-INFO +5 -3
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/README.md +4 -2
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/pyproject.toml +1 -1
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/__init__.py +16 -6
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/exceptions.py +8 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/loadContent.py +9 -3
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/pyhtml.py +1 -1
- {pywsgiref-1.1.11 → pywsgiref-1.1.13/src/PyWSGIRef.egg-info}/PKG-INFO +5 -3
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/LICENSE +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/setup.cfg +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/__main__.py +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/beta.py +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/commons.py +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/defaults.py +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/finished.py +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/patterns.py +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/simpleServer.py +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef/templateDict.py +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef.egg-info/SOURCES.txt +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef.egg-info/dependency_links.txt +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef.egg-info/requires.txt +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/src/PyWSGIRef.egg-info/top_level.txt +0 -0
- {pywsgiref-1.1.11 → pywsgiref-1.1.13}/tests/testMainServer.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyWSGIRef
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.13
|
|
4
4
|
Summary: easy server-setup
|
|
5
5
|
Author-email: Leander Kafemann <leander@kafemann.berlin>
|
|
6
6
|
Project-URL: Homepage, https://github.com/LeanderKafemann/PyWSGIRef
|
|
@@ -159,6 +159,9 @@ just use the <code><{{evalPyHTML}}></code> phrase at the end of the document and
|
|
|
159
159
|
PyWSGIRef will automatically add the closing html and body tags.<br/><br/>
|
|
160
160
|
You can also add PyWSGIRef's own, featured modern stylesheet using:<br/>
|
|
161
161
|
<code><{{evalPyHTML-modernStyling: true}}></code> inside the head block of your PyHTML file.<br/><br/>
|
|
162
|
+
You may add your own static resources like CSS or JavaScript files using the <code><{{evalPyHTML-include: ... :include-}}></code> phrase.<br/>
|
|
163
|
+
Different static resources can be included by separating them with a comma.<br/>
|
|
164
|
+
You may include CSS, JS, JSON and ICO files.<br/><br/>
|
|
162
165
|
With the <code><{{evalPyHTML-script: alert('Hello, World!'); :script-}}></code> phrase,<br/>
|
|
163
166
|
you can add a script block anywhere inside your PyHTML file.<br/>
|
|
164
167
|
Using pretty much the same syntax, you can also add a style block using
|
|
@@ -193,8 +196,7 @@ BETA.enable()
|
|
|
193
196
|
```
|
|
194
197
|
Currently to be tested are:<br/>
|
|
195
198
|
- PyHTML python script blocks<br/>
|
|
196
|
-
- PyHTML python if clause blocks<br/>
|
|
197
|
-
- PyHTML include static resource blocks<br/><br/>
|
|
199
|
+
- PyHTML python if clause blocks<br/><br/>
|
|
198
200
|
|
|
199
201
|
Thanks a lot for helping improving PyWSGIRef!
|
|
200
202
|
### More coming soon
|
|
@@ -142,6 +142,9 @@ just use the <code><{{evalPyHTML}}></code> phrase at the end of the document and
|
|
|
142
142
|
PyWSGIRef will automatically add the closing html and body tags.<br/><br/>
|
|
143
143
|
You can also add PyWSGIRef's own, featured modern stylesheet using:<br/>
|
|
144
144
|
<code><{{evalPyHTML-modernStyling: true}}></code> inside the head block of your PyHTML file.<br/><br/>
|
|
145
|
+
You may add your own static resources like CSS or JavaScript files using the <code><{{evalPyHTML-include: ... :include-}}></code> phrase.<br/>
|
|
146
|
+
Different static resources can be included by separating them with a comma.<br/>
|
|
147
|
+
You may include CSS, JS, JSON and ICO files.<br/><br/>
|
|
145
148
|
With the <code><{{evalPyHTML-script: alert('Hello, World!'); :script-}}></code> phrase,<br/>
|
|
146
149
|
you can add a script block anywhere inside your PyHTML file.<br/>
|
|
147
150
|
Using pretty much the same syntax, you can also add a style block using
|
|
@@ -176,8 +179,7 @@ BETA.enable()
|
|
|
176
179
|
```
|
|
177
180
|
Currently to be tested are:<br/>
|
|
178
181
|
- PyHTML python script blocks<br/>
|
|
179
|
-
- PyHTML python if clause blocks<br/>
|
|
180
|
-
- PyHTML include static resource blocks<br/><br/>
|
|
182
|
+
- PyHTML python if clause blocks<br/><br/>
|
|
181
183
|
|
|
182
184
|
Thanks a lot for helping improving PyWSGIRef!
|
|
183
185
|
### More coming soon
|
|
@@ -17,8 +17,8 @@ def about():
|
|
|
17
17
|
"""
|
|
18
18
|
Returns information about your release and other projects by Leander Kafemann
|
|
19
19
|
"""
|
|
20
|
-
return {"Version": (1, 1,
|
|
21
|
-
"recommend": ("Buero by LK", "pyimager by LK"), "feedbackTo": "
|
|
20
|
+
return {"Version": (1, 1, 13), "Author": "Leander Kafemann", "date": "13.08.2025",\
|
|
21
|
+
"recommend": ("Buero by LK", "pyimager by LK"), "feedbackTo": "update-bot@lk.kafemann.berlin"}
|
|
22
22
|
|
|
23
23
|
SCHABLONEN = TemplateDict()
|
|
24
24
|
|
|
@@ -31,12 +31,13 @@ def addSchablone(name: str, content: str):
|
|
|
31
31
|
raise ServerAlreadyGeneratedError()
|
|
32
32
|
SCHABLONEN[name] = PyHTML(content)
|
|
33
33
|
|
|
34
|
-
def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool = False, setAdvancedHeaders: bool = False) -> Callable:
|
|
34
|
+
def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool = False, setAdvancedHeaders: bool = False, getIP: bool = False) -> Callable:
|
|
35
35
|
"""
|
|
36
36
|
Returns a WSGI application object based on your contentGeneratingFunction.
|
|
37
37
|
The contentGeneratingFunction should take a single argument (the path) and return the content as a string.
|
|
38
38
|
If advanced is True, the contentGeneratingFunction will receive a FieldStorage object as the second argument.
|
|
39
39
|
If setAdvancedHeaders is True, it will allow you to set advanced headers for the response.
|
|
40
|
+
If getIP is True, the contentGeneratingFunction will receive the IP address of the client as an additional argument.
|
|
40
41
|
"""
|
|
41
42
|
if not callable(contentGeneratingFunction):
|
|
42
43
|
raise InvalidCallableError()
|
|
@@ -49,13 +50,22 @@ def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool =
|
|
|
49
50
|
if advanced:
|
|
50
51
|
storage = FieldStorage(fp=environ.get("wsgi.input"), environ=environ, keep_blank_values=True)
|
|
51
52
|
if setAdvancedHeaders:
|
|
52
|
-
|
|
53
|
+
if getIP:
|
|
54
|
+
content, type_, status = contentGeneratingFunction(environ["PATH_INFO"], storage, environ["HTTP_X_REAL_IP"])
|
|
55
|
+
else:
|
|
56
|
+
content, type_, status = contentGeneratingFunction(environ["PATH_INFO"], storage)
|
|
53
57
|
else:
|
|
54
|
-
|
|
58
|
+
if getIP:
|
|
59
|
+
content = contentGeneratingFunction(environ["PATH_INFO"], storage, environ["HTTP_X_REAL_IP"])
|
|
60
|
+
else:
|
|
61
|
+
content = contentGeneratingFunction(environ["PATH_INFO"], storage)
|
|
55
62
|
else:
|
|
56
63
|
if setAdvancedHeaders:
|
|
57
64
|
raise AdvancedHeadersWithoutAdvancedModeError()
|
|
58
|
-
|
|
65
|
+
if getIP:
|
|
66
|
+
content = contentGeneratingFunction(environ["PATH_INFO"], environ["HTTP_X_REAL_IP"])
|
|
67
|
+
else:
|
|
68
|
+
content = contentGeneratingFunction(environ["PATH_INFO"])
|
|
59
69
|
headers = [("Content-Type", type_),
|
|
60
70
|
("Content-Length", str(len(content))),
|
|
61
71
|
('Access-Control-Allow-Origin', '*')]
|
|
@@ -60,5 +60,13 @@ class BetaAlreadyEnabledError(BooleanAlreadyTrueError):
|
|
|
60
60
|
Raised when trying to enable beta mode that is already enabled.
|
|
61
61
|
"""
|
|
62
62
|
def __init__(self, message="Beta mode is already enabled."):
|
|
63
|
+
self.message = message
|
|
64
|
+
super().__init__(self.message)
|
|
65
|
+
|
|
66
|
+
class AccessToTemplateForbidden(Exception):
|
|
67
|
+
"""
|
|
68
|
+
Raised when trying to access a template that is not allowed.
|
|
69
|
+
"""
|
|
70
|
+
def __init__(self, message="Access to this template is forbidden."):
|
|
63
71
|
self.message = message
|
|
64
72
|
super().__init__(self.message)
|
|
@@ -6,7 +6,7 @@ import requests
|
|
|
6
6
|
from .exceptions import *
|
|
7
7
|
from .finished import finished
|
|
8
8
|
|
|
9
|
-
def loadFromWeb(url: str
|
|
9
|
+
def loadFromWeb(url: str) -> str:
|
|
10
10
|
"""
|
|
11
11
|
Loads content from the given URL with the given data.
|
|
12
12
|
"""
|
|
@@ -14,8 +14,14 @@ def loadFromWeb(url: str, data: dict = {}) -> str:
|
|
|
14
14
|
raise ServerAlreadyGeneratedError()
|
|
15
15
|
if not url.endswith(".pyhtml"):
|
|
16
16
|
raise InvalidFiletypeError()
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
|
|
18
|
+
# trick GitHub Pages guardian
|
|
19
|
+
headers = {"User-Agent": "Mozilla/5.0", "realAccessDeviceMonitorAgent": "PyWSGIRef/1.1"}
|
|
20
|
+
rq = requests.get(url, headers=headers)
|
|
21
|
+
if rq.status_code != 200:
|
|
22
|
+
raise AccessToTemplateForbidden()
|
|
23
|
+
rq_content = rq.content
|
|
24
|
+
return rq_content.decode()
|
|
19
25
|
|
|
20
26
|
def loadFromFile(filename: str) -> str:
|
|
21
27
|
"""
|
|
@@ -127,8 +127,8 @@ class PyHTML:
|
|
|
127
127
|
self._replace_modern_styling()
|
|
128
128
|
self._replace_script_blocks()
|
|
129
129
|
self._replace_style_blocks()
|
|
130
|
+
self._replace_includes()
|
|
130
131
|
if BETA.value:
|
|
131
|
-
self._replace_includes()
|
|
132
132
|
self._replace_eval_blocks()
|
|
133
133
|
self._replace_if_blocks()
|
|
134
134
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyWSGIRef
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.13
|
|
4
4
|
Summary: easy server-setup
|
|
5
5
|
Author-email: Leander Kafemann <leander@kafemann.berlin>
|
|
6
6
|
Project-URL: Homepage, https://github.com/LeanderKafemann/PyWSGIRef
|
|
@@ -159,6 +159,9 @@ just use the <code><{{evalPyHTML}}></code> phrase at the end of the document and
|
|
|
159
159
|
PyWSGIRef will automatically add the closing html and body tags.<br/><br/>
|
|
160
160
|
You can also add PyWSGIRef's own, featured modern stylesheet using:<br/>
|
|
161
161
|
<code><{{evalPyHTML-modernStyling: true}}></code> inside the head block of your PyHTML file.<br/><br/>
|
|
162
|
+
You may add your own static resources like CSS or JavaScript files using the <code><{{evalPyHTML-include: ... :include-}}></code> phrase.<br/>
|
|
163
|
+
Different static resources can be included by separating them with a comma.<br/>
|
|
164
|
+
You may include CSS, JS, JSON and ICO files.<br/><br/>
|
|
162
165
|
With the <code><{{evalPyHTML-script: alert('Hello, World!'); :script-}}></code> phrase,<br/>
|
|
163
166
|
you can add a script block anywhere inside your PyHTML file.<br/>
|
|
164
167
|
Using pretty much the same syntax, you can also add a style block using
|
|
@@ -193,8 +196,7 @@ BETA.enable()
|
|
|
193
196
|
```
|
|
194
197
|
Currently to be tested are:<br/>
|
|
195
198
|
- PyHTML python script blocks<br/>
|
|
196
|
-
- PyHTML python if clause blocks<br/>
|
|
197
|
-
- PyHTML include static resource blocks<br/><br/>
|
|
199
|
+
- PyHTML python if clause blocks<br/><br/>
|
|
198
200
|
|
|
199
201
|
Thanks a lot for helping improving PyWSGIRef!
|
|
200
202
|
### More coming soon
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|