tina4-python 0.1.97__tar.gz → 0.1.99__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.
Files changed (39) hide show
  1. {tina4_python-0.1.97 → tina4_python-0.1.99}/PKG-INFO +1 -2
  2. {tina4_python-0.1.97 → tina4_python-0.1.99}/README.md +0 -1
  3. {tina4_python-0.1.97 → tina4_python-0.1.99}/pyproject.toml +1 -1
  4. tina4_python-0.1.99/tina4_python/__init__.py +226 -0
  5. tina4_python-0.1.97/tina4_python/__init__.py +0 -213
  6. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Auth.py +0 -0
  7. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Constant.py +0 -0
  8. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Database.py +0 -0
  9. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/DatabaseResult.py +0 -0
  10. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Debug.py +0 -0
  11. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Env.py +0 -0
  12. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Localization.py +0 -0
  13. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Messages.py +0 -0
  14. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Migration.py +0 -0
  15. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Request.py +0 -0
  16. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Response.py +0 -0
  17. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Router.py +0 -0
  18. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Session.py +0 -0
  19. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/ShellColors.py +0 -0
  20. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Swagger.py +0 -0
  21. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Template.py +0 -0
  22. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/Webserver.py +0 -0
  23. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/messages.pot +0 -0
  24. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/css/readme.md +0 -0
  25. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/favicon.ico +0 -0
  26. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/images/403.png +0 -0
  27. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/images/404.png +0 -0
  28. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/images/logo.png +0 -0
  29. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/images/readme.md +0 -0
  30. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/js/readme.md +0 -0
  31. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/swagger/index.html +0 -0
  32. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
  33. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/templates/errors/403.twig +0 -0
  34. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/templates/errors/404.twig +0 -0
  35. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/templates/readme.md +0 -0
  36. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  37. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  38. {tina4_python-0.1.97 → tina4_python-0.1.99}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  39. {tina4_python-0.1.97 → tina4_python-0.1.99}/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.97
3
+ Version: 0.1.99
4
4
  Summary: Tina4Python - This is not another framework for Python
5
5
  Author: Andre van Zuydam
6
6
  Author-email: andrevanzuydam@gmail.com
@@ -374,7 +374,6 @@ Migration updates:
374
374
  - Database result object updated
375
375
  ```
376
376
 
377
-
378
377
  ### Building and Deployment
379
378
 
380
379
  #### Using Python
@@ -353,7 +353,6 @@ Migration updates:
353
353
  - Database result object updated
354
354
  ```
355
355
 
356
-
357
356
  ### Building and Deployment
358
357
 
359
358
  #### Using Python
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tina4-python"
3
- version = "0.1.97"
3
+ version = "0.1.99"
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"
@@ -0,0 +1,226 @@
1
+ #
2
+ # Tina4 - This is not a 4ramework.
3
+ # Copy-right 2007 - current Tina4
4
+ # License: MIT https://opensource.org/licenses/MIT
5
+ #
6
+ # flake8: noqa: E403,F401,E402
7
+ import asyncio
8
+ import gettext
9
+ import os
10
+ import shutil
11
+ import importlib
12
+ import sys
13
+ import sass
14
+ from pathlib import Path
15
+ from watchdog.observers import Observer
16
+ from watchdog.events import FileSystemEventHandler, FileSystemEvent
17
+
18
+ from tina4_python.Router import get
19
+ from tina4_python import Messages, Constant
20
+ from tina4_python.Swagger import Swagger
21
+ from tina4_python.Env import load_env
22
+ from tina4_python.Webserver import Webserver
23
+ from tina4_python.Router import Router, get
24
+ from tina4_python.Localization import localize
25
+ from tina4_python.Auth import Auth
26
+ from tina4_python.Debug import Debug
27
+ from tina4_python.ShellColors import ShellColors
28
+
29
+ _ = gettext.gettext
30
+
31
+ # Server startup messages
32
+ MSG_ASSUMING_ROOT_PATH = _('Assuming root path: {root_path}, library path: {library_path}')
33
+ MSG_LOAD_ALL_THINGS = _('Load all things')
34
+ MSG_SERVER_STARTED = _('Server started http://{host_name}:{port}')
35
+ MSG_SERVER_STOPPED = _('Server stopped.')
36
+ MSG_STARTING_WEBSERVER = _('Starting webserver on {port}')
37
+ MSG_ENTRY_POINT_NAME = _('Entry point name ... {name}')
38
+
39
+ if os.getenv('environment') is not None:
40
+ environment = ".env." + os.getenv('environment')
41
+ else:
42
+ environment = ".env"
43
+
44
+ load_env(environment)
45
+ if os.getenv('TINA4_DEFAULT_WEBSERVER', 'True') == 'True' :
46
+ print(ShellColors.bright_yellow + "Setting debug mode", os.getenv("TINA4_DEBUG_LEVEL"), ShellColors.end)
47
+ localize()
48
+
49
+ if importlib.util.find_spec("jurigged"):
50
+ import jurigged
51
+
52
+ # Define the variable to be used for global routes
53
+ library_path = os.path.dirname(os.path.realpath(__file__))
54
+ root_path = os.path.realpath(os.getcwd())
55
+ Debug(Messages.MSG_ASSUMING_ROOT_PATH.format(root_path=root_path, library_path=library_path),
56
+ Constant.TINA4_LOG_INFO)
57
+
58
+
59
+ tina4_routes = {}
60
+ tina4_current_request = {}
61
+ tina4_secret = None
62
+ tina4_auth = Auth(root_path)
63
+
64
+ token = tina4_auth.get_token({"name": "Tina4"})
65
+ Debug("TEST TOKEN", token, Constant.TINA4_LOG_DEBUG)
66
+ Debug("VALID TOKEN", tina4_auth.valid(token + "a"), Constant.TINA4_LOG_DEBUG)
67
+ Debug("VALID TOKEN", tina4_auth.valid(token), Constant.TINA4_LOG_DEBUG)
68
+ Debug("PAYLOAD", tina4_auth.get_payload(token), Constant.TINA4_LOG_DEBUG)
69
+
70
+ if "TINA4_SECRET" in os.environ:
71
+ tina4_secret = os.environ["TINA4_SECRET"]
72
+
73
+ # Hack for local development
74
+ if root_path.count("tina4_python") > 0:
75
+ root_path = root_path.split("tina4_python")[0][:-1]
76
+
77
+ # Make the beginning files for the tina4stack
78
+ if not os.path.exists(root_path + os.sep + "src"):
79
+ os.makedirs(root_path + os.sep + "src" + os.sep + "routes")
80
+ os.makedirs(root_path + os.sep + "src" + os.sep + "scss")
81
+ os.makedirs(root_path + os.sep + "src" + os.sep + "orm")
82
+ os.makedirs(root_path + os.sep + "src" + os.sep + "app")
83
+ with open(root_path + os.sep + "src" + os.sep + "__init__.py", 'w') as init_file:
84
+ init_file.write('# Start your project here')
85
+ init_file.write('\n')
86
+ if not os.path.isfile(root_path + os.sep + "app.py") and not os.path.isdir(root_path + os.sep + "tina4_python"):
87
+ with open(root_path + os.sep + "app.py", 'w') as app_file:
88
+ app_file.write('# Starting point for tina4_python, you shouldn''t need to change anything here')
89
+ app_file.write('\n')
90
+ app_file.write('from tina4_python import *')
91
+ app_file.write('\n')
92
+
93
+ if not os.path.exists(root_path + os.sep + "src" + os.sep + "app"):
94
+ os.makedirs(root_path + os.sep + "src" + os.sep + "app")
95
+
96
+ # copy over templates if needed - required for errors
97
+ if not os.path.exists(root_path + os.sep + "src" + os.sep + "templates"):
98
+ source_dir = library_path + os.sep + "templates"
99
+ destination_dir = root_path + os.sep + "src" + os.sep + "templates"
100
+ shutil.copytree(source_dir, destination_dir)
101
+
102
+ # copy over public if needed - required for static files like images and logos
103
+ if not os.path.exists(root_path + os.sep + "src" + os.sep + "public"):
104
+ source_dir = library_path + os.sep + "public"
105
+ destination_dir = root_path + os.sep + "src" + os.sep + "public"
106
+ shutil.copytree(source_dir, destination_dir)
107
+
108
+ # please keep in place otherwise autoloading of files does not work nicely, if you want this to work
109
+ # add __init__.py files in your folders
110
+ # ignore F403
111
+ if os.path.exists(root_path + os.sep + "src"):
112
+ try:
113
+ from src import *
114
+ except ImportError:
115
+ Debug("Cannot import src folder", Constant.TINA4_LOG_ERROR)
116
+ else:
117
+ Debug("Missing src folder", Constant.TINA4_LOG_WARNING)
118
+
119
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "routes"):
120
+ try:
121
+ from src.routes import *
122
+ except ImportError:
123
+ Debug("Cannot import src.routes folder", Constant.TINA4_LOG_ERROR)
124
+ else:
125
+ Debug("Missing src/routes folder", Constant.TINA4_LOG_WARNING)
126
+
127
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "app"):
128
+ try:
129
+ from src.app import *
130
+ except ImportError:
131
+ Debug("Cannot import src.app folder", Constant.TINA4_LOG_ERROR)
132
+ else:
133
+ Debug("Missing src/app folder", Constant.TINA4_LOG_WARNING)
134
+
135
+ # compile sass
136
+ def compile_scss():
137
+ try:
138
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
139
+ Debug("Compiling scss", Constant.TINA4_LOG_DEBUG)
140
+ sass.compile(dirname=(root_path + os.sep + 'src' + os.sep + 'scss',
141
+ root_path + os.sep + 'src' + os.sep + 'public' + os.sep + 'css'),
142
+ output_style='compressed')
143
+ except sass.CompileError as E:
144
+ Debug('Error compiling SASS ', E, Constant.TINA4_LOG_ERROR)
145
+
146
+
147
+ compile_scss()
148
+
149
+
150
+ class SassCompiler(FileSystemEventHandler):
151
+ def on_modified(self, event: FileSystemEvent) -> None:
152
+ if not event.is_directory:
153
+ compile_scss()
154
+
155
+
156
+ if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
157
+ observer = Observer()
158
+ event_handler = SassCompiler()
159
+ observer.schedule(event_handler, path=root_path + os.sep + "src" + os.sep + "scss", recursive=True)
160
+ observer.start()
161
+ else:
162
+ Debug("Missing scss folder", Constant.TINA4_LOG_WARNING)
163
+
164
+ # end compile sass
165
+
166
+
167
+ def file_get_contents(file_path):
168
+ return Path(file_path).read_text()
169
+
170
+ # Add swagger routes
171
+ @get("/swagger/swagger.json")
172
+ async def get_swagger_json(request, response):
173
+ json = Swagger.get_json(request)
174
+ return response(json)
175
+
176
+ @get("/swagger")
177
+ async def get_swagger(request, response):
178
+ html = file_get_contents(root_path + os.sep +"src"+os.sep+"public"+ os.sep+"swagger"+os.sep+"index.html")
179
+ return response(html)
180
+
181
+ def webserver(host_name, port):
182
+ web_server = Webserver(host_name, int(port)) # HTTPServer((host_name, int(port)), Webserver)
183
+ web_server.router_handler = Router()
184
+ # Fix the display to make it clickable
185
+ if host_name == "0.0.0.0":
186
+ host_name = "localhost"
187
+ Debug(Messages.MSG_SERVER_STARTED.format(host_name=host_name, port=port), Constant.TINA4_LOG_INFO)
188
+ try:
189
+ asyncio.run(web_server.serve_forever())
190
+ except KeyboardInterrupt:
191
+ pass
192
+ web_server.server_close()
193
+ Debug(Messages.MSG_SERVER_STOPPED, Constant.TINA4_LOG_INFO)
194
+
195
+
196
+ def run_web_server(in_hostname="localhost", in_port=7145):
197
+ Debug(Messages.MSG_STARTING_WEBSERVER.format(port=in_port), Constant.TINA4_LOG_INFO)
198
+ webserver(in_hostname, in_port)
199
+
200
+ if importlib.util.find_spec("jurigged"):
201
+ Debug("Jurigged enabled", Constant.TINA4_LOG_INFO)
202
+ jurigged.watch("./")
203
+
204
+ # Start up a webserver based on params passed on the command line
205
+ HOSTNAME = "localhost"
206
+ PORT = 7145
207
+ if len(sys.argv) > 1:
208
+ PORT = sys.argv[1]
209
+ if ":" in PORT:
210
+ SERVER_CONFIG = PORT.split(":")
211
+ HOSTNAME = SERVER_CONFIG[0]
212
+ PORT = SERVER_CONFIG[1]
213
+
214
+ if PORT != "stop" and PORT != "manual":
215
+ try:
216
+ PORT = int(PORT)
217
+ run_web_server(HOSTNAME, PORT)
218
+ except Exception:
219
+ Debug("Not running webserver", Constant.TINA4_LOG_WARNING)
220
+ else:
221
+ Debug("Webserver is set to manual start, please call " + ShellColors.bright_red +
222
+ "run_web_server(<HOSTNAME>, <PORT>)" + ShellColors.end + " in your code",
223
+ Constant.TINA4_LOG_WARNING)
224
+ else:
225
+ library_path = os.path.dirname(os.path.realpath(__file__))
226
+ root_path = os.path.realpath(os.getcwd())
@@ -1,213 +0,0 @@
1
- #
2
- # Tina4 - This is not a 4ramework.
3
- # Copy-right 2007 - current Tina4
4
- # License: MIT https://opensource.org/licenses/MIT
5
- #
6
- # flake8: noqa: E403,F401,E402
7
- import asyncio
8
- import gettext
9
- import os
10
- import shutil
11
- import importlib
12
- import sys
13
- import sass
14
- from pathlib import Path
15
- from watchdog.observers import Observer
16
- from watchdog.events import FileSystemEventHandler, FileSystemEvent
17
-
18
- from tina4_python.Router import get
19
- from tina4_python import Messages, Constant
20
- from tina4_python.Swagger import Swagger
21
- from tina4_python.Env import load_env
22
- from tina4_python.Webserver import Webserver
23
- from tina4_python.Router import Router, get
24
- from tina4_python.Localization import localize
25
- from tina4_python.Auth import Auth
26
- from tina4_python.Debug import Debug
27
- from tina4_python.ShellColors import ShellColors
28
-
29
- _ = gettext.gettext
30
-
31
- # Server startup messages
32
- MSG_ASSUMING_ROOT_PATH = _('Assuming root path: {root_path}, library path: {library_path}')
33
- MSG_LOAD_ALL_THINGS = _('Load all things')
34
- MSG_SERVER_STARTED = _('Server started http://{host_name}:{port}')
35
- MSG_SERVER_STOPPED = _('Server stopped.')
36
- MSG_STARTING_WEBSERVER = _('Starting webserver on {port}')
37
- MSG_ENTRY_POINT_NAME = _('Entry point name ... {name}')
38
-
39
- if os.getenv('environment') is not None:
40
- environment = ".env." + os.getenv('environment')
41
- else:
42
- environment = ".env"
43
-
44
- load_env(environment)
45
- print(ShellColors.bright_yellow + "Setting debug mode", os.getenv("TINA4_DEBUG_LEVEL"), ShellColors.end)
46
- localize()
47
-
48
- if importlib.util.find_spec("jurigged"):
49
- import jurigged
50
-
51
- # Define the variable to be used for global routes
52
- library_path = os.path.dirname(os.path.realpath(__file__))
53
- root_path = os.path.realpath(os.getcwd())
54
- Debug(Messages.MSG_ASSUMING_ROOT_PATH.format(root_path=root_path, library_path=library_path),
55
- Constant.TINA4_LOG_INFO)
56
-
57
- tina4_routes = {}
58
- tina4_current_request = {}
59
- tina4_secret = None
60
- tina4_auth = Auth(root_path)
61
-
62
- token = tina4_auth.get_token({"name": "Tina4"})
63
- Debug("TEST TOKEN", token, Constant.TINA4_LOG_DEBUG)
64
- Debug("VALID TOKEN", tina4_auth.valid(token + "a"), Constant.TINA4_LOG_DEBUG)
65
- Debug("VALID TOKEN", tina4_auth.valid(token), Constant.TINA4_LOG_DEBUG)
66
- Debug("PAYLOAD", tina4_auth.get_payload(token), Constant.TINA4_LOG_DEBUG)
67
-
68
- if "TINA4_SECRET" in os.environ:
69
- tina4_secret = os.environ["TINA4_SECRET"]
70
-
71
- # Hack for local development
72
- if root_path.count("tina4_python") > 0:
73
- root_path = root_path.split("tina4_python")[0][:-1]
74
-
75
- # Make the beginning files for the tina4stack
76
- if not os.path.exists(root_path + os.sep + "src"):
77
- os.makedirs(root_path + os.sep + "src" + os.sep + "routes")
78
- os.makedirs(root_path + os.sep + "src" + os.sep + "scss")
79
- os.makedirs(root_path + os.sep + "src" + os.sep + "orm")
80
- os.makedirs(root_path + os.sep + "src" + os.sep + "app")
81
- with open(root_path + os.sep + "src" + os.sep + "__init__.py", 'w') as init_file:
82
- init_file.write('# Start your project here')
83
- init_file.write('\n')
84
- if not os.path.isfile(root_path + os.sep + "app.py") and not os.path.isdir(root_path + os.sep + "tina4_python"):
85
- with open(root_path + os.sep + "app.py", 'w') as app_file:
86
- app_file.write('# Starting point for tina4_python, you shouldn''t need to change anything here')
87
- app_file.write('\n')
88
- app_file.write('from tina4_python import *')
89
- app_file.write('\n')
90
-
91
- if not os.path.exists(root_path + os.sep + "src" + os.sep + "app"):
92
- os.makedirs(root_path + os.sep + "src" + os.sep + "app")
93
-
94
- # copy over templates if needed - required for errors
95
- if not os.path.exists(root_path + os.sep + "src" + os.sep + "templates"):
96
- source_dir = library_path + os.sep + "templates"
97
- destination_dir = root_path + os.sep + "src" + os.sep + "templates"
98
- shutil.copytree(source_dir, destination_dir)
99
-
100
- # copy over public if needed - required for static files like images and logos
101
- if not os.path.exists(root_path + os.sep + "src" + os.sep + "public"):
102
- source_dir = library_path + os.sep + "public"
103
- destination_dir = root_path + os.sep + "src" + os.sep + "public"
104
- shutil.copytree(source_dir, destination_dir)
105
-
106
- # please keep in place otherwise autoloading of files does not work nicely, if you want this to work
107
- # add __init__.py files in your folders
108
- # ignore F403
109
- if os.path.exists(root_path + os.sep + "src"):
110
- from src import *
111
- else:
112
- Debug("Missing src folder", Constant.TINA4_LOG_WARNING)
113
-
114
- if os.path.exists(root_path + os.sep + "src" + os.sep + "routes"):
115
- from src.routes import *
116
- else:
117
- Debug("Missing src/routes folder", Constant.TINA4_LOG_WARNING)
118
-
119
- if os.path.exists(root_path + os.sep + "src" + os.sep + "app"):
120
- from src.app import *
121
- else:
122
- Debug("Missing src/app folder", Constant.TINA4_LOG_WARNING)
123
-
124
- # compile sass
125
- def compile_scss():
126
- try:
127
- if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
128
- Debug("Compiling scss", Constant.TINA4_LOG_DEBUG)
129
- sass.compile(dirname=(root_path + os.sep + 'src' + os.sep + 'scss',
130
- root_path + os.sep + 'src' + os.sep + 'public' + os.sep + 'css'),
131
- output_style='compressed')
132
- except sass.CompileError as E:
133
- Debug('Error compiling SASS ', E, Constant.TINA4_LOG_ERROR)
134
-
135
-
136
- compile_scss()
137
-
138
-
139
- class SassCompiler(FileSystemEventHandler):
140
- def on_modified(self, event: FileSystemEvent) -> None:
141
- if not event.is_directory:
142
- compile_scss()
143
-
144
-
145
- if os.path.exists(root_path + os.sep + "src" + os.sep + "scss"):
146
- observer = Observer()
147
- event_handler = SassCompiler()
148
- observer.schedule(event_handler, path=root_path + os.sep + "src" + os.sep + "scss", recursive=True)
149
- observer.start()
150
- else:
151
- Debug("Missing scss folder", Constant.TINA4_LOG_WARNING)
152
-
153
- # end compile sass
154
-
155
-
156
- def file_get_contents(file_path):
157
- return Path(file_path).read_text()
158
-
159
- # Add swagger routes
160
- @get("/swagger/swagger.json")
161
- async def get_swagger_json(request, response):
162
- json = Swagger.get_json(request)
163
- return response(json)
164
-
165
- @get("/swagger")
166
- async def get_swagger(request, response):
167
- html = file_get_contents(root_path + os.sep +"src"+os.sep+"public"+ os.sep+"swagger"+os.sep+"index.html")
168
- return response(html)
169
-
170
- def webserver(host_name, port):
171
- web_server = Webserver(host_name, int(port)) # HTTPServer((host_name, int(port)), Webserver)
172
- web_server.router_handler = Router()
173
- # Fix the display to make it clickable
174
- if host_name == "0.0.0.0":
175
- host_name = "localhost"
176
- Debug(Messages.MSG_SERVER_STARTED.format(host_name=host_name, port=port), Constant.TINA4_LOG_INFO)
177
- try:
178
- asyncio.run(web_server.serve_forever())
179
- except KeyboardInterrupt:
180
- pass
181
- web_server.server_close()
182
- Debug(Messages.MSG_SERVER_STOPPED, Constant.TINA4_LOG_INFO)
183
-
184
-
185
- def run_web_server(in_hostname="localhost", in_port=7145):
186
- Debug(Messages.MSG_STARTING_WEBSERVER.format(port=in_port), Constant.TINA4_LOG_INFO)
187
- webserver(in_hostname, in_port)
188
-
189
- if os.getenv('TINA4_DEFAULT_WEBSERVER', 'True') == 'True' :
190
- if importlib.util.find_spec("jurigged"):
191
- Debug("Jurigged enabled", Constant.TINA4_LOG_INFO)
192
- jurigged.watch("./")
193
-
194
- # Start up a webserver based on params passed on the command line
195
- HOSTNAME = "localhost"
196
- PORT = 7145
197
- if len(sys.argv) > 1:
198
- PORT = sys.argv[1]
199
- if ":" in PORT:
200
- SERVER_CONFIG = PORT.split(":")
201
- HOSTNAME = SERVER_CONFIG[0]
202
- PORT = SERVER_CONFIG[1]
203
-
204
- if PORT != "stop" and PORT != "manual":
205
- try:
206
- PORT = int(PORT)
207
- run_web_server(HOSTNAME, PORT)
208
- except Exception:
209
- Debug("Not running webserver", Constant.TINA4_LOG_WARNING)
210
- else:
211
- Debug("Webserver is set to manual start, please call " + ShellColors.bright_red +
212
- "run_web_server(<HOSTNAME>, <PORT>)" + ShellColors.end + " in your code",
213
- Constant.TINA4_LOG_WARNING)