PyWSGIRef 1.1.19__tar.gz → 1.1.20__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.19/src/PyWSGIRef.egg-info → pywsgiref-1.1.20}/PKG-INFO +3 -2
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/README.md +2 -1
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/pyproject.toml +1 -1
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/__init__.py +25 -3
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/exceptions.py +8 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20/src/PyWSGIRef.egg-info}/PKG-INFO +3 -2
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/LICENSE +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/setup.cfg +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/__main__.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/beta.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/commons.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/defaults.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/finished.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/loadContent.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/patterns.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/pyhtml.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/simpleServer.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/stats.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef/templateDict.py +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef.egg-info/SOURCES.txt +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef.egg-info/dependency_links.txt +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef.egg-info/requires.txt +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/src/PyWSGIRef.egg-info/top_level.txt +0 -0
- {pywsgiref-1.1.19 → pywsgiref-1.1.20}/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.20
|
|
4
4
|
Summary: easy server-setup
|
|
5
5
|
Author-email: Leander Kafemann <leander.kafemann+python@icloud.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/LeanderKafemann/PyWSGIRef
|
|
@@ -96,7 +96,8 @@ html = loadFromFile('index.pyhtml')
|
|
|
96
96
|
html = loadFromWeb('https://example.com/index.pyhtml')
|
|
97
97
|
```
|
|
98
98
|
This is useful for serving dynamic HTML content in your WSGI application.<br/>
|
|
99
|
-
The funcs are callable unless you set up a server
|
|
99
|
+
The funcs are callable unless you set up a server.<br/>
|
|
100
|
+
You can also add multiple PyHTML files from the web at the same time using the <code>multiWebInit</code> function.
|
|
100
101
|
### Using Templates
|
|
101
102
|
PyWSGIRef also provides a simple way to use templates in your WSGI application:
|
|
102
103
|
```python
|
|
@@ -79,7 +79,8 @@ html = loadFromFile('index.pyhtml')
|
|
|
79
79
|
html = loadFromWeb('https://example.com/index.pyhtml')
|
|
80
80
|
```
|
|
81
81
|
This is useful for serving dynamic HTML content in your WSGI application.<br/>
|
|
82
|
-
The funcs are callable unless you set up a server
|
|
82
|
+
The funcs are callable unless you set up a server.<br/>
|
|
83
|
+
You can also add multiple PyHTML files from the web at the same time using the <code>multiWebInit</code> function.
|
|
83
84
|
### Using Templates
|
|
84
85
|
PyWSGIRef also provides a simple way to use templates in your WSGI application:
|
|
85
86
|
```python
|
|
@@ -18,7 +18,7 @@ def about():
|
|
|
18
18
|
"""
|
|
19
19
|
Returns information about your release and other projects by Leander Kafemann
|
|
20
20
|
"""
|
|
21
|
-
return {"Version": (1, 1,
|
|
21
|
+
return {"Version": (1, 1, 20), "Author": "Leander Kafemann", "date": "26.08.2026",\
|
|
22
22
|
"recommend": ("pyimager"), "feedbackTo": "leander.kafemann+python@icloud.com"}
|
|
23
23
|
|
|
24
24
|
SCHABLONEN = TemplateDict()
|
|
@@ -33,6 +33,21 @@ def addSchablone(name: str, content: str):
|
|
|
33
33
|
raise ServerAlreadyGeneratedError()
|
|
34
34
|
SCHABLONEN[name] = PyHTML(content)
|
|
35
35
|
|
|
36
|
+
def multiWebInit(baseURL: str, templateNames: list[str], overrideException: bool = False) -> list[str]:
|
|
37
|
+
"""
|
|
38
|
+
Loads multiple templates from the web and adds them to the SCHABLONEN dictionary.
|
|
39
|
+
Returns a list of the names of the loaded templates.
|
|
40
|
+
"""
|
|
41
|
+
if finished.value and not overrideException:
|
|
42
|
+
raise ServerAlreadyGeneratedError()
|
|
43
|
+
loadedTemplates = []
|
|
44
|
+
for name in templateNames:
|
|
45
|
+
url = f"{baseURL}/{name}.pyhtml"
|
|
46
|
+
content = loadFromWeb(url, overrideException=overrideException)
|
|
47
|
+
addSchablone(name, content)
|
|
48
|
+
loadedTemplates.append(name)
|
|
49
|
+
return loadedTemplates
|
|
50
|
+
|
|
36
51
|
def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool = False, setAdvancedHeaders: bool = False,\
|
|
37
52
|
getIP: bool = False, vercelPythonHosting: bool = False, getStats: bool = False,
|
|
38
53
|
advancedStats: bool = False, customEncoding: bool = False) -> Callable:
|
|
@@ -51,6 +66,7 @@ def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool =
|
|
|
51
66
|
if not callable(contentGeneratingFunction):
|
|
52
67
|
raise InvalidCallableError()
|
|
53
68
|
BETA.lock()
|
|
69
|
+
|
|
54
70
|
def simpleApplication(environ, start_response) -> list:
|
|
55
71
|
"""
|
|
56
72
|
A simple WSGI application object that serves as a template.
|
|
@@ -61,8 +77,13 @@ def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool =
|
|
|
61
77
|
STATS.count.increase()
|
|
62
78
|
perfTime = STATS.startPerfTime("applicationCallNr"+str(STATS.count.count))
|
|
63
79
|
storage = FieldStorage(fp=environ.get("wsgi.input"), environ=environ, keep_blank_values=True)
|
|
64
|
-
|
|
65
|
-
|
|
80
|
+
try:
|
|
81
|
+
if storage.getvalue("realAccessDeviceMonitorAgent", "") not in ["PyWSGIRef/1.1", ""]:
|
|
82
|
+
raise OutdatedPyWSGIRefVersionError("Access with outdated PyWSGIRef version detected. Please update to the latest version.")
|
|
83
|
+
except TypeError:
|
|
84
|
+
pass
|
|
85
|
+
except:
|
|
86
|
+
raise InvalidEnvironError("Invalid WSGI environ and/or FieldStorage keys detected.")
|
|
66
87
|
type_ = "text/html"
|
|
67
88
|
status = "200 OK"
|
|
68
89
|
if advanced:
|
|
@@ -98,6 +119,7 @@ def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool =
|
|
|
98
119
|
else:
|
|
99
120
|
if customEncoding:
|
|
100
121
|
raise VercelIncompabilityError("customEncoding cannot be used with vercelPythonHosting.")
|
|
122
|
+
|
|
101
123
|
return simpleApplication
|
|
102
124
|
|
|
103
125
|
def setUpServer(application: Callable, port: int = 8000) -> WSGIServer:
|
|
@@ -100,5 +100,13 @@ class OutdatedPyWSGIRefVersionError(Exception):
|
|
|
100
100
|
Raised when the PyWSGIRef version is outdated and does not support a requested feature.
|
|
101
101
|
"""
|
|
102
102
|
def __init__(self, message="The PyWSGIRef version is outdated and does not support this feature."):
|
|
103
|
+
self.message = message
|
|
104
|
+
super().__init__(self.message)
|
|
105
|
+
|
|
106
|
+
class InvalidEnvironError(Exception):
|
|
107
|
+
"""
|
|
108
|
+
Raised when the WSGI environ is invalid or missing required keys.
|
|
109
|
+
"""
|
|
110
|
+
def __init__(self, message="Invalid WSGI environ."):
|
|
103
111
|
self.message = message
|
|
104
112
|
super().__init__(self.message)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyWSGIRef
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.20
|
|
4
4
|
Summary: easy server-setup
|
|
5
5
|
Author-email: Leander Kafemann <leander.kafemann+python@icloud.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/LeanderKafemann/PyWSGIRef
|
|
@@ -96,7 +96,8 @@ html = loadFromFile('index.pyhtml')
|
|
|
96
96
|
html = loadFromWeb('https://example.com/index.pyhtml')
|
|
97
97
|
```
|
|
98
98
|
This is useful for serving dynamic HTML content in your WSGI application.<br/>
|
|
99
|
-
The funcs are callable unless you set up a server
|
|
99
|
+
The funcs are callable unless you set up a server.<br/>
|
|
100
|
+
You can also add multiple PyHTML files from the web at the same time using the <code>multiWebInit</code> function.
|
|
100
101
|
### Using Templates
|
|
101
102
|
PyWSGIRef also provides a simple way to use templates in your WSGI application:
|
|
102
103
|
```python
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|