PyWSGIRef 1.1.13__tar.gz → 1.1.14__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.13/src/PyWSGIRef.egg-info → pywsgiref-1.1.14}/PKG-INFO +4 -3
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/README.md +2 -1
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/pyproject.toml +2 -2
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/__init__.py +20 -5
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/beta.py +11 -1
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/exceptions.py +16 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/pyhtml.py +1 -1
- pywsgiref-1.1.14/src/PyWSGIRef/stats.py +18 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14/src/PyWSGIRef.egg-info}/PKG-INFO +4 -3
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef.egg-info/SOURCES.txt +1 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/LICENSE +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/setup.cfg +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/__main__.py +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/commons.py +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/defaults.py +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/finished.py +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/loadContent.py +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/patterns.py +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/simpleServer.py +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef/templateDict.py +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef.egg-info/dependency_links.txt +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef.egg-info/requires.txt +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/src/PyWSGIRef.egg-info/top_level.txt +0 -0
- {pywsgiref-1.1.13 → pywsgiref-1.1.14}/tests/testMainServer.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyWSGIRef
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.14
|
|
4
4
|
Summary: easy server-setup
|
|
5
|
-
Author-email: Leander Kafemann <leander@
|
|
5
|
+
Author-email: Leander Kafemann <leander.kafemann+python@icloud.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/LeanderKafemann/PyWSGIRef
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -196,7 +196,8 @@ BETA.enable()
|
|
|
196
196
|
```
|
|
197
197
|
Currently to be tested are:<br/>
|
|
198
198
|
- PyHTML python script blocks<br/>
|
|
199
|
-
- PyHTML python if clause blocks<br
|
|
199
|
+
- PyHTML python if clause blocks<br/>
|
|
200
|
+
- stats for the application object<br/><br/>
|
|
200
201
|
|
|
201
202
|
Thanks a lot for helping improving PyWSGIRef!
|
|
202
203
|
### More coming soon
|
|
@@ -179,7 +179,8 @@ BETA.enable()
|
|
|
179
179
|
```
|
|
180
180
|
Currently to be tested are:<br/>
|
|
181
181
|
- PyHTML python script blocks<br/>
|
|
182
|
-
- PyHTML python if clause blocks<br
|
|
182
|
+
- PyHTML python if clause blocks<br/>
|
|
183
|
+
- stats for the application object<br/><br/>
|
|
183
184
|
|
|
184
185
|
Thanks a lot for helping improving PyWSGIRef!
|
|
185
186
|
### More coming soon
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "PyWSGIRef"
|
|
3
|
-
version = "1.1.
|
|
3
|
+
version = "1.1.14"
|
|
4
4
|
authors = [
|
|
5
|
-
{name="Leander Kafemann", email="leander@
|
|
5
|
+
{name="Leander Kafemann", email="leander.kafemann+python@icloud.com" },
|
|
6
6
|
]
|
|
7
7
|
description = "easy server-setup"
|
|
8
8
|
readme = "README.md"
|
|
@@ -12,15 +12,18 @@ from .templateDict import TemplateDict
|
|
|
12
12
|
from .beta import BETA
|
|
13
13
|
from .loadContent import *
|
|
14
14
|
from .finished import finished
|
|
15
|
+
from .stats import Stats
|
|
15
16
|
|
|
16
17
|
def about():
|
|
17
18
|
"""
|
|
18
19
|
Returns information about your release and other projects by Leander Kafemann
|
|
19
20
|
"""
|
|
20
|
-
return {"Version": (1, 1,
|
|
21
|
-
"recommend": ("
|
|
21
|
+
return {"Version": (1, 1, 14), "Author": "Leander Kafemann", "date": "05.09.2025",\
|
|
22
|
+
"recommend": ("pyimager"), "feedbackTo": "leander.kafemann+python@icloud.com"}
|
|
22
23
|
|
|
23
24
|
SCHABLONEN = TemplateDict()
|
|
25
|
+
STATS = Stats()
|
|
26
|
+
COUNT = 0
|
|
24
27
|
|
|
25
28
|
def addSchablone(name: str, content: str):
|
|
26
29
|
"""
|
|
@@ -31,20 +34,30 @@ def addSchablone(name: str, content: str):
|
|
|
31
34
|
raise ServerAlreadyGeneratedError()
|
|
32
35
|
SCHABLONEN[name] = PyHTML(content)
|
|
33
36
|
|
|
34
|
-
def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool = False, setAdvancedHeaders: bool = False
|
|
37
|
+
def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool = False, setAdvancedHeaders: bool = False,\
|
|
38
|
+
getIP: bool = False, vercelPythonHosting: bool = False, getStats: bool = True) -> Callable:
|
|
35
39
|
"""
|
|
36
40
|
Returns a WSGI application object based on your contentGeneratingFunction.
|
|
37
41
|
The contentGeneratingFunction should take a single argument (the path) and return the content as a string.
|
|
38
42
|
If advanced is True, the contentGeneratingFunction will receive a FieldStorage object as the second argument.
|
|
39
43
|
If setAdvancedHeaders is True, it will allow you to set advanced headers for the response.
|
|
40
44
|
If getIP is True, the contentGeneratingFunction will receive the IP address of the client as an additional argument.
|
|
45
|
+
If vercelPythonHosting is True, your application object will be optimized for Vercel's unusual WSGI methods.
|
|
46
|
+
If getStats is True, stats are saved in the STATS object.
|
|
47
|
+
Locks BETA mode.
|
|
41
48
|
"""
|
|
42
49
|
if not callable(contentGeneratingFunction):
|
|
43
50
|
raise InvalidCallableError()
|
|
51
|
+
BETA.lock()
|
|
44
52
|
def simpleApplication(environ, start_response) -> list:
|
|
45
53
|
"""
|
|
46
54
|
A simple WSGI application object that serves as a template.
|
|
47
55
|
"""
|
|
56
|
+
if getStats:
|
|
57
|
+
if not BETA.value:
|
|
58
|
+
raise BetaNotEnabledError()
|
|
59
|
+
COUNT += 1
|
|
60
|
+
perfTime = STATS.startPerfTime("applicationCallNr"+str(COUNT))
|
|
48
61
|
type_ = "text/html"
|
|
49
62
|
status = "200 OK"
|
|
50
63
|
if advanced:
|
|
@@ -70,13 +83,15 @@ def makeApplicationObject(contentGeneratingFunction: Callable, advanced: bool =
|
|
|
70
83
|
("Content-Length", str(len(content))),
|
|
71
84
|
('Access-Control-Allow-Origin', '*')]
|
|
72
85
|
start_response(status, headers)
|
|
73
|
-
|
|
86
|
+
STATS.stopPerfTime(perfTime)
|
|
87
|
+
if not vercelPythonHosting:
|
|
88
|
+
return [content.encode("utf-8")]
|
|
74
89
|
return simpleApplication
|
|
75
90
|
|
|
76
91
|
def setUpServer(application: Callable, port: int = 8000) -> WSGIServer:
|
|
77
92
|
"""
|
|
78
93
|
Creates a WSGI server.
|
|
79
|
-
No additional
|
|
94
|
+
No additional templates can be loaded from the web.
|
|
80
95
|
"""
|
|
81
96
|
finished.set_true()
|
|
82
97
|
server = make_server('', port, application)
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
BETA mode...
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from .exceptions import
|
|
5
|
+
from .exceptions import *
|
|
6
|
+
from .finished import OneWayBoolean
|
|
6
7
|
|
|
7
8
|
class beta:
|
|
8
9
|
"""
|
|
@@ -10,6 +11,7 @@ class beta:
|
|
|
10
11
|
"""
|
|
11
12
|
def __init__(self):
|
|
12
13
|
self._beta = False
|
|
14
|
+
self.locked = OneWayBoolean()
|
|
13
15
|
|
|
14
16
|
@property
|
|
15
17
|
def value(self) -> bool:
|
|
@@ -21,8 +23,16 @@ class beta:
|
|
|
21
23
|
"""
|
|
22
24
|
if self._beta:
|
|
23
25
|
raise BetaAlreadyEnabledError()
|
|
26
|
+
if self.locked.value:
|
|
27
|
+
raise BetaAlreadyLocked()
|
|
24
28
|
self._beta = True
|
|
25
29
|
|
|
30
|
+
def lock(self):
|
|
31
|
+
"""
|
|
32
|
+
Locks current value of beta
|
|
33
|
+
"""
|
|
34
|
+
self.locked.set_true()
|
|
35
|
+
|
|
26
36
|
BETA = beta()
|
|
27
37
|
|
|
28
38
|
def enableBetaMode():
|
|
@@ -68,5 +68,21 @@ class AccessToTemplateForbidden(Exception):
|
|
|
68
68
|
Raised when trying to access a template that is not allowed.
|
|
69
69
|
"""
|
|
70
70
|
def __init__(self, message="Access to this template is forbidden."):
|
|
71
|
+
self.message = message
|
|
72
|
+
super().__init__(self.message)
|
|
73
|
+
|
|
74
|
+
class BetaAlreadyLocked(Exception):
|
|
75
|
+
"""
|
|
76
|
+
Raised when trying to activate BETA mode when it is already locked.
|
|
77
|
+
"""
|
|
78
|
+
def __init__(self, message="BETA mode already locked"):
|
|
79
|
+
self.message = message
|
|
80
|
+
super().__init__(self.message)
|
|
81
|
+
|
|
82
|
+
class BetaNotEnabledError(Exception):
|
|
83
|
+
"""
|
|
84
|
+
Raised when trying to use a BETA feature when BETA mode is not enabled.
|
|
85
|
+
"""
|
|
86
|
+
def __init__(self, message="BETA mode is not enabled."):
|
|
71
87
|
self.message = message
|
|
72
88
|
super().__init__(self.message)
|
|
@@ -20,7 +20,7 @@ class PyHTML:
|
|
|
20
20
|
if self.html.startswith(EVAL_PYHTML):
|
|
21
21
|
self.html = START_REPLACE + self.html[len(EVAL_PYHTML):]
|
|
22
22
|
if self.html.endswith(EVAL_PYHTML):
|
|
23
|
-
self.html = self.html[:-len(EVAL_PYHTML)] + END_REPLACE
|
|
23
|
+
self.html = self.html[:-len(EVAL_PYHTML)-1] + END_REPLACE
|
|
24
24
|
|
|
25
25
|
def _replace_modern_styling(self):
|
|
26
26
|
"""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
|
|
3
|
+
class PerformanceTime:
|
|
4
|
+
def __init__(self, title: str):
|
|
5
|
+
self.start = datetime.datetime.now()
|
|
6
|
+
self.title = title
|
|
7
|
+
def stop(self):
|
|
8
|
+
self.end = datetime.datetime.now()
|
|
9
|
+
|
|
10
|
+
class Stats:
|
|
11
|
+
def __init__(self):
|
|
12
|
+
self.performanceTimes = []
|
|
13
|
+
|
|
14
|
+
def startPerfTime(self, title: str = "perfTime") -> PerformanceTime:
|
|
15
|
+
return PerformanceTime(title)
|
|
16
|
+
def stopPerfTime(self, perfTime: PerformanceTime):
|
|
17
|
+
perfTime.stop()
|
|
18
|
+
self.performanceTimes.append(perfTime)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyWSGIRef
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.14
|
|
4
4
|
Summary: easy server-setup
|
|
5
|
-
Author-email: Leander Kafemann <leander@
|
|
5
|
+
Author-email: Leander Kafemann <leander.kafemann+python@icloud.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/LeanderKafemann/PyWSGIRef
|
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -196,7 +196,8 @@ BETA.enable()
|
|
|
196
196
|
```
|
|
197
197
|
Currently to be tested are:<br/>
|
|
198
198
|
- PyHTML python script blocks<br/>
|
|
199
|
-
- PyHTML python if clause blocks<br
|
|
199
|
+
- PyHTML python if clause blocks<br/>
|
|
200
|
+
- stats for the application object<br/><br/>
|
|
200
201
|
|
|
201
202
|
Thanks a lot for helping improving PyWSGIRef!
|
|
202
203
|
### 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
|