tina4-python 0.1.45__tar.gz → 0.1.46__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.
- {tina4_python-0.1.45 → tina4_python-0.1.46}/PKG-INFO +26 -19
- {tina4_python-0.1.45 → tina4_python-0.1.46}/README.md +25 -18
- {tina4_python-0.1.45 → tina4_python-0.1.46}/pyproject.toml +1 -4
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Webserver.py +2 -2
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/__init__.py +24 -24
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Auth.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Constant.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Debug.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Env.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Localization.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Messages.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Request.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Response.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Router.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/Template.py +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/messages.pot +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/public/css/readme.md +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/public/favicon.ico +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/public/images/403.png +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/public/images/404.png +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/public/images/logo.png +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/public/images/readme.md +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/public/js/readme.md +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/templates/errors/403.twig +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/templates/errors/404.twig +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/templates/readme.md +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
- {tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tina4-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.46
|
|
4
4
|
Summary: Tina4Python - This is not another framework for Python
|
|
5
5
|
Author: Andre van Zuydam
|
|
6
6
|
Author-email: andrevanzuydam@gmail.com
|
|
@@ -40,6 +40,7 @@ After installing poetry you can do the following:
|
|
|
40
40
|
poetry new project-name
|
|
41
41
|
cd project-name
|
|
42
42
|
poetry add tina4_python
|
|
43
|
+
poetry add jurigged
|
|
43
44
|
```
|
|
44
45
|
Create an entry point for Tina4 called ```app.py``` and add the following to the file
|
|
45
46
|
```python
|
|
@@ -85,30 +86,33 @@ After defining templates and routes, run the Tina4Python server:
|
|
|
85
86
|
|
|
86
87
|
- **Normal Server**:
|
|
87
88
|
```bash
|
|
88
|
-
poetry run
|
|
89
|
+
poetry run python app.py
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
- **Server with Hot Reloading**:
|
|
92
93
|
```bash
|
|
93
|
-
poetry run jurigged
|
|
94
|
+
poetry run jurigged app.py
|
|
94
95
|
```
|
|
95
96
|
|
|
96
97
|
- **Server on a Specific Port**:
|
|
97
98
|
```bash
|
|
98
|
-
poetry run app.py 7777
|
|
99
|
+
poetry run python app.py 7777
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- **Server to not autostart **:
|
|
103
|
+
```bash
|
|
104
|
+
poetry run python app.py manual
|
|
99
105
|
```
|
|
100
106
|
|
|
101
107
|
- **Server with alternate language** (for example fr = French):
|
|
102
108
|
```bash
|
|
103
|
-
poetry run
|
|
109
|
+
poetry run python app.py fr
|
|
104
110
|
```
|
|
105
111
|
|
|
106
112
|
Add more translations by going [here](TRANSLATIONS.md)
|
|
107
113
|
|
|
108
114
|
### Templating
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Tina4 uses [Twig](https://twig.symfony.com/) templating to provide a simple and efficient way to create web pages.
|
|
115
|
+
Tina4 uses Jinja2 (Twig) templating to provide a simple and efficient way to create web pages.
|
|
112
116
|
|
|
113
117
|
1.) **Twig Files**: Add your Twig files within the `src/templates` folder. For instance, you might create files like `index.twig`, `base.twig`, etc., containing your HTML structure with Twig templating syntax for dynamic content.
|
|
114
118
|
|
|
@@ -219,18 +223,21 @@ For ease of use you can supply an `API_KEY` param to your .env with a secret of
|
|
|
219
223
|
API_KEY=somehash
|
|
220
224
|
```
|
|
221
225
|
|
|
226
|
+
|
|
222
227
|
### Features
|
|
223
|
-
| Completed | To Do
|
|
224
|
-
|
|
225
|
-
| Python pip package |
|
|
226
|
-
| Basic environment handling |
|
|
227
|
-
| Basic routing | OpenAPI (Swagger)
|
|
228
|
-
| Enhanced routing |
|
|
229
|
-
| CSS Support |
|
|
230
|
-
| Image Support |
|
|
231
|
-
| Localization |
|
|
232
|
-
| Error Pages |
|
|
233
|
-
| Template handling |
|
|
228
|
+
| Completed | To Do |
|
|
229
|
+
|----------------------------|-------------------|
|
|
230
|
+
| Python pip package | |
|
|
231
|
+
| Basic environment handling | |
|
|
232
|
+
| Basic routing | OpenAPI (Swagger) |
|
|
233
|
+
| Enhanced routing | |
|
|
234
|
+
| CSS Support | |
|
|
235
|
+
| Image Support | |
|
|
236
|
+
| Localization | |
|
|
237
|
+
| Error Pages | |
|
|
238
|
+
| Template handling | |
|
|
239
|
+
| Form posting | |
|
|
240
|
+
| JWT tokens & security | |
|
|
234
241
|
|
|
235
242
|
### Building and Deployment
|
|
236
243
|
|
|
@@ -21,6 +21,7 @@ After installing poetry you can do the following:
|
|
|
21
21
|
poetry new project-name
|
|
22
22
|
cd project-name
|
|
23
23
|
poetry add tina4_python
|
|
24
|
+
poetry add jurigged
|
|
24
25
|
```
|
|
25
26
|
Create an entry point for Tina4 called ```app.py``` and add the following to the file
|
|
26
27
|
```python
|
|
@@ -66,30 +67,33 @@ After defining templates and routes, run the Tina4Python server:
|
|
|
66
67
|
|
|
67
68
|
- **Normal Server**:
|
|
68
69
|
```bash
|
|
69
|
-
poetry run
|
|
70
|
+
poetry run python app.py
|
|
70
71
|
```
|
|
71
72
|
|
|
72
73
|
- **Server with Hot Reloading**:
|
|
73
74
|
```bash
|
|
74
|
-
poetry run jurigged
|
|
75
|
+
poetry run jurigged app.py
|
|
75
76
|
```
|
|
76
77
|
|
|
77
78
|
- **Server on a Specific Port**:
|
|
78
79
|
```bash
|
|
79
|
-
poetry run app.py 7777
|
|
80
|
+
poetry run python app.py 7777
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- **Server to not autostart **:
|
|
84
|
+
```bash
|
|
85
|
+
poetry run python app.py manual
|
|
80
86
|
```
|
|
81
87
|
|
|
82
88
|
- **Server with alternate language** (for example fr = French):
|
|
83
89
|
```bash
|
|
84
|
-
poetry run
|
|
90
|
+
poetry run python app.py fr
|
|
85
91
|
```
|
|
86
92
|
|
|
87
93
|
Add more translations by going [here](TRANSLATIONS.md)
|
|
88
94
|
|
|
89
95
|
### Templating
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Tina4 uses [Twig](https://twig.symfony.com/) templating to provide a simple and efficient way to create web pages.
|
|
96
|
+
Tina4 uses Jinja2 (Twig) templating to provide a simple and efficient way to create web pages.
|
|
93
97
|
|
|
94
98
|
1.) **Twig Files**: Add your Twig files within the `src/templates` folder. For instance, you might create files like `index.twig`, `base.twig`, etc., containing your HTML structure with Twig templating syntax for dynamic content.
|
|
95
99
|
|
|
@@ -200,18 +204,21 @@ For ease of use you can supply an `API_KEY` param to your .env with a secret of
|
|
|
200
204
|
API_KEY=somehash
|
|
201
205
|
```
|
|
202
206
|
|
|
207
|
+
|
|
203
208
|
### Features
|
|
204
|
-
| Completed | To Do
|
|
205
|
-
|
|
206
|
-
| Python pip package |
|
|
207
|
-
| Basic environment handling |
|
|
208
|
-
| Basic routing | OpenAPI (Swagger)
|
|
209
|
-
| Enhanced routing |
|
|
210
|
-
| CSS Support |
|
|
211
|
-
| Image Support |
|
|
212
|
-
| Localization |
|
|
213
|
-
| Error Pages |
|
|
214
|
-
| Template handling |
|
|
209
|
+
| Completed | To Do |
|
|
210
|
+
|----------------------------|-------------------|
|
|
211
|
+
| Python pip package | |
|
|
212
|
+
| Basic environment handling | |
|
|
213
|
+
| Basic routing | OpenAPI (Swagger) |
|
|
214
|
+
| Enhanced routing | |
|
|
215
|
+
| CSS Support | |
|
|
216
|
+
| Image Support | |
|
|
217
|
+
| Localization | |
|
|
218
|
+
| Error Pages | |
|
|
219
|
+
| Template handling | |
|
|
220
|
+
| Form posting | |
|
|
221
|
+
| JWT tokens & security | |
|
|
215
222
|
|
|
216
223
|
### Building and Deployment
|
|
217
224
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "tina4-python"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.46"
|
|
4
4
|
description = "Tina4Python - This is not another framework for Python"
|
|
5
5
|
authors = ["Andre van Zuydam <andrevanzuydam@gmail.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -18,9 +18,6 @@ cryptography = "^42.0.5"
|
|
|
18
18
|
pytest = "^7.2.0"
|
|
19
19
|
jurigged = "^0.5.3"
|
|
20
20
|
|
|
21
|
-
[tool.poetry.scripts]
|
|
22
|
-
run = "main:main"
|
|
23
|
-
|
|
24
21
|
[build-system]
|
|
25
22
|
requires = ["poetry-core>=1.0.0"]
|
|
26
23
|
build-backend = "poetry.core.masonry.api"
|
|
@@ -196,8 +196,8 @@ class Webserver:
|
|
|
196
196
|
self.router_handler = None
|
|
197
197
|
self.running = False
|
|
198
198
|
|
|
199
|
-
def serve_forever(self):
|
|
200
|
-
|
|
199
|
+
async def serve_forever(self):
|
|
200
|
+
await self.run_server()
|
|
201
201
|
|
|
202
202
|
def server_close(self):
|
|
203
203
|
self.running = False
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
# Copy-right 2007 - current Tina4
|
|
4
4
|
# License: MIT https://opensource.org/licenses/MIT
|
|
5
5
|
#
|
|
6
|
+
import asyncio
|
|
6
7
|
import gettext
|
|
7
8
|
import os
|
|
8
9
|
import shutil
|
|
9
10
|
import importlib
|
|
10
11
|
import sys
|
|
12
|
+
|
|
11
13
|
from tina4_python.Env import load_env
|
|
12
14
|
from tina4_python.Webserver import Webserver
|
|
13
15
|
from tina4_python.Router import Router
|
|
@@ -26,7 +28,7 @@ MSG_STARTING_WEBSERVER = _('Starting webserver on {port}')
|
|
|
26
28
|
MSG_ENTRY_POINT_NAME = _('Entry point name ... {name}')
|
|
27
29
|
|
|
28
30
|
if os.getenv('environment') is not None:
|
|
29
|
-
environment = ".env."+os.getenv('environment')
|
|
31
|
+
environment = ".env." + os.getenv('environment')
|
|
30
32
|
else:
|
|
31
33
|
environment = ".env"
|
|
32
34
|
|
|
@@ -48,7 +50,7 @@ tina4_auth = Auth(root_path)
|
|
|
48
50
|
|
|
49
51
|
token = tina4_auth.get_token({"name": "Tina4"})
|
|
50
52
|
print("TEST TOKEN", token)
|
|
51
|
-
print("VALID TOKEN", tina4_auth.valid(token+"a"))
|
|
53
|
+
print("VALID TOKEN", tina4_auth.valid(token + "a"))
|
|
52
54
|
print("VALID TOKEN", tina4_auth.valid(token))
|
|
53
55
|
print("PAYLOAD", tina4_auth.get_payload(token))
|
|
54
56
|
|
|
@@ -87,48 +89,46 @@ if not os.path.exists(root_path + os.sep + "src" + os.sep + "public"):
|
|
|
87
89
|
destination_dir = root_path + os.sep + "src" + os.sep + "public"
|
|
88
90
|
shutil.copytree(source_dir, destination_dir)
|
|
89
91
|
|
|
90
|
-
# please keep in place otherwise
|
|
92
|
+
# please keep in place otherwise autoloading of files does not work nicely
|
|
91
93
|
from src import *
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
print(Messages.MSG_LOAD_ALL_THINGS)
|
|
94
|
+
from src.routes import *
|
|
95
|
+
from src.app import *
|
|
95
96
|
|
|
96
97
|
|
|
97
98
|
def webserver(host_name, port):
|
|
98
99
|
web_server = Webserver(host_name, int(port)) # HTTPServer((host_name, int(port)), Webserver)
|
|
99
100
|
web_server.router_handler = Router()
|
|
100
101
|
print(Messages.MSG_SERVER_STARTED.format(host_name=host_name, port=port))
|
|
101
|
-
|
|
102
102
|
try:
|
|
103
|
-
web_server.serve_forever()
|
|
103
|
+
asyncio.run(web_server.serve_forever())
|
|
104
104
|
except KeyboardInterrupt:
|
|
105
105
|
pass
|
|
106
|
-
|
|
107
106
|
web_server.server_close()
|
|
108
107
|
print(Messages.MSG_SERVER_STOPPED)
|
|
109
108
|
|
|
110
109
|
|
|
111
|
-
def
|
|
110
|
+
def run_web_server(in_hostname="localhost", in_port=7145):
|
|
112
111
|
print(Messages.MSG_STARTING_WEBSERVER.format(port=in_port))
|
|
113
|
-
initialize()
|
|
114
112
|
webserver(in_hostname, in_port)
|
|
115
113
|
|
|
116
|
-
|
|
117
114
|
if importlib.util.find_spec("jurigged"):
|
|
118
115
|
print("Jurigged enabled")
|
|
119
116
|
jurigged.watch("./")
|
|
120
117
|
|
|
121
|
-
print(Messages.MSG_ENTRY_POINT_NAME.format(name=__name__))
|
|
122
|
-
if __name__ == '__main__' or __name__ == 'tina4_python':
|
|
123
|
-
# Start up a webserver based on params passed on the command line
|
|
124
|
-
HOSTNAME = "localhost"
|
|
125
|
-
PORT = 7145
|
|
126
|
-
if len(sys.argv) > 1:
|
|
127
|
-
PORT = sys.argv[1]
|
|
128
|
-
if ":" in PORT:
|
|
129
|
-
SERVER_CONFIG = PORT.split(":")
|
|
130
|
-
HOSTNAME = SERVER_CONFIG[0]
|
|
131
|
-
PORT = SERVER_CONFIG[1]
|
|
132
118
|
|
|
119
|
+
# Start up a webserver based on params passed on the command line
|
|
120
|
+
HOSTNAME = "localhost"
|
|
121
|
+
PORT = 7145
|
|
122
|
+
if len(sys.argv) > 1:
|
|
123
|
+
PORT = sys.argv[1]
|
|
124
|
+
if ":" in PORT:
|
|
125
|
+
SERVER_CONFIG = PORT.split(":")
|
|
126
|
+
HOSTNAME = SERVER_CONFIG[0]
|
|
127
|
+
PORT = SERVER_CONFIG[1]
|
|
128
|
+
|
|
129
|
+
if PORT != "stop" and PORT != "manual":
|
|
133
130
|
PORT = int(PORT)
|
|
134
|
-
|
|
131
|
+
print("Threading")
|
|
132
|
+
run_web_server(HOSTNAME, PORT)
|
|
133
|
+
else:
|
|
134
|
+
print("Webserver is set to manual start, please call run_web_server(HOSTNAME, PORT)")
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/translations/en/LC_MESSAGES/messages.mo
RENAMED
|
File without changes
|
{tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/translations/en/LC_MESSAGES/messages.po
RENAMED
|
File without changes
|
{tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/translations/fr/LC_MESSAGES/messages.mo
RENAMED
|
File without changes
|
{tina4_python-0.1.45 → tina4_python-0.1.46}/tina4_python/translations/fr/LC_MESSAGES/messages.po
RENAMED
|
File without changes
|