OpenGeodeWeb-Back 5.10.2__py3-none-any.whl → 5.10.3rc1__py3-none-any.whl
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.
Potentially problematic release.
This version of OpenGeodeWeb-Back might be problematic. Click here for more details.
- opengeodeweb_back/app.py +156 -0
- opengeodeweb_back/app_config.py +1 -10
- opengeodeweb_back/utils_functions.py +0 -5
- {opengeodeweb_back-5.10.2.dist-info → opengeodeweb_back-5.10.3rc1.dist-info}/METADATA +3 -3
- {opengeodeweb_back-5.10.2.dist-info → opengeodeweb_back-5.10.3rc1.dist-info}/RECORD +9 -7
- opengeodeweb_back-5.10.3rc1.dist-info/entry_points.txt +2 -0
- {opengeodeweb_back-5.10.2.dist-info → opengeodeweb_back-5.10.3rc1.dist-info}/WHEEL +0 -0
- {opengeodeweb_back-5.10.2.dist-info → opengeodeweb_back-5.10.3rc1.dist-info}/licenses/LICENSE +0 -0
- {opengeodeweb_back-5.10.2.dist-info → opengeodeweb_back-5.10.3rc1.dist-info}/top_level.txt +0 -0
opengeodeweb_back/app.py
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""Packages"""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import os
|
|
5
|
+
import time
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import flask
|
|
9
|
+
import flask_cors # type: ignore
|
|
10
|
+
from flask import Flask, Response
|
|
11
|
+
from flask_cors import cross_origin
|
|
12
|
+
from werkzeug.exceptions import HTTPException
|
|
13
|
+
|
|
14
|
+
from opengeodeweb_back import utils_functions, app_config
|
|
15
|
+
from opengeodeweb_back.routes import blueprint_routes
|
|
16
|
+
from opengeodeweb_back.routes.models import blueprint_models
|
|
17
|
+
from opengeodeweb_microservice.database.connection import init_database
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
""" Global config """
|
|
21
|
+
app: Flask = flask.Flask(__name__)
|
|
22
|
+
|
|
23
|
+
""" Config variables """
|
|
24
|
+
FLASK_DEBUG = True if os.environ.get("FLASK_DEBUG", default=None) == "True" else False
|
|
25
|
+
|
|
26
|
+
if FLASK_DEBUG == False:
|
|
27
|
+
app.config.from_object(app_config.ProdConfig)
|
|
28
|
+
else:
|
|
29
|
+
app.config.from_object(app_config.DevConfig)
|
|
30
|
+
|
|
31
|
+
DEFAULT_HOST: str = app.config.get("DEFAULT_HOST") or "localhost"
|
|
32
|
+
DEFAULT_PORT: int = int(app.config.get("DEFAULT_PORT") or 5000)
|
|
33
|
+
DEFAULT_DATA_FOLDER_PATH: str = app.config.get("DEFAULT_DATA_FOLDER_PATH") or "./data"
|
|
34
|
+
ORIGINS: Any = app.config.get("ORIGINS")
|
|
35
|
+
TIMEOUT: int = int(app.config.get("MINUTES_BEFORE_TIMEOUT") or 30)
|
|
36
|
+
SSL: Any = app.config.get("SSL")
|
|
37
|
+
SECONDS_BETWEEN_SHUTDOWNS: float = float(
|
|
38
|
+
app.config.get("SECONDS_BETWEEN_SHUTDOWNS") or 60.0
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
app.register_blueprint(
|
|
43
|
+
blueprint_routes.routes,
|
|
44
|
+
url_prefix="/opengeodeweb_back",
|
|
45
|
+
name="opengeodeweb_back",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
app.register_blueprint(
|
|
49
|
+
blueprint_models.routes,
|
|
50
|
+
url_prefix="/opengeodeweb_back/models",
|
|
51
|
+
name="opengeodeweb_models",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if FLASK_DEBUG == False:
|
|
55
|
+
utils_functions.set_interval(
|
|
56
|
+
utils_functions.kill_task, SECONDS_BETWEEN_SHUTDOWNS, app
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@app.errorhandler(HTTPException)
|
|
61
|
+
def errorhandler(e: HTTPException) -> tuple[dict[str, Any], int] | Response:
|
|
62
|
+
return utils_functions.handle_exception(e)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@app.route(
|
|
66
|
+
"/error",
|
|
67
|
+
methods=["POST"],
|
|
68
|
+
)
|
|
69
|
+
def return_error() -> Response:
|
|
70
|
+
flask.abort(500, f"Test")
|
|
71
|
+
return flask.make_response({}, 500)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@app.route("/", methods=["POST"])
|
|
75
|
+
@cross_origin()
|
|
76
|
+
def root() -> Response:
|
|
77
|
+
return flask.make_response({}, 200)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@app.route("/kill", methods=["POST"])
|
|
81
|
+
@cross_origin()
|
|
82
|
+
def kill() -> None:
|
|
83
|
+
print("Manual server kill, shutting down...", flush=True)
|
|
84
|
+
os._exit(0)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def run_server() -> None:
|
|
88
|
+
parser = argparse.ArgumentParser(
|
|
89
|
+
prog="OpenGeodeWeb-Back", description="Backend server for OpenGeodeWeb"
|
|
90
|
+
)
|
|
91
|
+
parser.add_argument("--host", type=str, default=DEFAULT_HOST, help="Host to run on")
|
|
92
|
+
parser.add_argument(
|
|
93
|
+
"-p", "--port", type=int, default=DEFAULT_PORT, help="Port to listen on"
|
|
94
|
+
)
|
|
95
|
+
parser.add_argument(
|
|
96
|
+
"-d",
|
|
97
|
+
"--debug",
|
|
98
|
+
default=FLASK_DEBUG,
|
|
99
|
+
help="Whether to run in debug mode",
|
|
100
|
+
action="store_true",
|
|
101
|
+
)
|
|
102
|
+
parser.add_argument(
|
|
103
|
+
"-dfp",
|
|
104
|
+
"--data_folder_path",
|
|
105
|
+
type=str,
|
|
106
|
+
default=DEFAULT_DATA_FOLDER_PATH,
|
|
107
|
+
help="Path to the folder where data is stored",
|
|
108
|
+
)
|
|
109
|
+
parser.add_argument(
|
|
110
|
+
"-ufp",
|
|
111
|
+
"--upload_folder_path",
|
|
112
|
+
type=str,
|
|
113
|
+
default=DEFAULT_DATA_FOLDER_PATH,
|
|
114
|
+
help="Path to the folder where uploads are stored",
|
|
115
|
+
)
|
|
116
|
+
parser.add_argument(
|
|
117
|
+
"-origins",
|
|
118
|
+
"--allowed_origins",
|
|
119
|
+
default=ORIGINS,
|
|
120
|
+
help="Origins that are allowed to connect to the server",
|
|
121
|
+
)
|
|
122
|
+
parser.add_argument(
|
|
123
|
+
"-t",
|
|
124
|
+
"--timeout",
|
|
125
|
+
default=TIMEOUT,
|
|
126
|
+
help="Number of minutes before the server times out",
|
|
127
|
+
)
|
|
128
|
+
args = parser.parse_args()
|
|
129
|
+
|
|
130
|
+
app.config.update(DATA_FOLDER_PATH=args.data_folder_path)
|
|
131
|
+
app.config.update(UPLOAD_FOLDER=args.upload_folder_path)
|
|
132
|
+
app.config.update(MINUTES_BEFORE_TIMEOUT=args.timeout)
|
|
133
|
+
|
|
134
|
+
flask_cors.CORS(app, origins=args.allowed_origins)
|
|
135
|
+
|
|
136
|
+
print(
|
|
137
|
+
f"Host: {args.host}, Port: {args.port}, Debug: {args.debug}, "
|
|
138
|
+
f"Data folder path: {args.data_folder_path}, Timeout: {args.timeout}, "
|
|
139
|
+
f"Origins: {args.allowed_origins}",
|
|
140
|
+
flush=True,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
db_filename: str = app.config.get("DATABASE_FILENAME") or "database.db"
|
|
144
|
+
db_path = os.path.join(args.data_folder_path, db_filename)
|
|
145
|
+
os.makedirs(os.path.dirname(db_path), exist_ok=True)
|
|
146
|
+
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{db_path}"
|
|
147
|
+
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
|
148
|
+
init_database(app, db_filename)
|
|
149
|
+
print(f"Database initialized at: {db_path}", flush=True)
|
|
150
|
+
|
|
151
|
+
app.run(debug=args.debug, host=args.host, port=args.port, ssl_context=SSL)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# ''' Main '''
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
run_server()
|
opengeodeweb_back/app_config.py
CHANGED
|
@@ -4,9 +4,6 @@ import time
|
|
|
4
4
|
|
|
5
5
|
# Third party imports
|
|
6
6
|
# Local application imports
|
|
7
|
-
from opengeodeweb_microservice.database.connection import get_database
|
|
8
|
-
|
|
9
|
-
DATABASE_FILENAME = "project.db"
|
|
10
7
|
|
|
11
8
|
|
|
12
9
|
class Config(object):
|
|
@@ -18,7 +15,7 @@ class Config(object):
|
|
|
18
15
|
REQUEST_COUNTER = 0
|
|
19
16
|
LAST_REQUEST_TIME = time.time()
|
|
20
17
|
LAST_PING_TIME = time.time()
|
|
21
|
-
|
|
18
|
+
DATABASE_FILENAME = "project.db"
|
|
22
19
|
|
|
23
20
|
|
|
24
21
|
class ProdConfig(Config):
|
|
@@ -27,9 +24,6 @@ class ProdConfig(Config):
|
|
|
27
24
|
MINUTES_BEFORE_TIMEOUT = "1"
|
|
28
25
|
SECONDS_BETWEEN_SHUTDOWNS = "10"
|
|
29
26
|
DATA_FOLDER_PATH = "/data"
|
|
30
|
-
SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.abspath(
|
|
31
|
-
os.path.join(DATA_FOLDER_PATH, DATABASE_FILENAME)
|
|
32
|
-
)}"
|
|
33
27
|
|
|
34
28
|
|
|
35
29
|
class DevConfig(Config):
|
|
@@ -39,6 +33,3 @@ class DevConfig(Config):
|
|
|
39
33
|
SECONDS_BETWEEN_SHUTDOWNS = "10"
|
|
40
34
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
41
35
|
DATA_FOLDER_PATH = os.path.join(BASE_DIR, "data")
|
|
42
|
-
SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.join(
|
|
43
|
-
BASE_DIR, DATA_FOLDER_PATH, DATABASE_FILENAME
|
|
44
|
-
)}"
|
|
@@ -88,7 +88,6 @@ def validate_request(request: flask.Request, schema: dict[str, str]) -> None:
|
|
|
88
88
|
|
|
89
89
|
if json_data is None:
|
|
90
90
|
json_data = {}
|
|
91
|
-
|
|
92
91
|
try:
|
|
93
92
|
validate = fastjsonschema.compile(schema)
|
|
94
93
|
validate(json_data)
|
|
@@ -259,10 +258,6 @@ def generate_native_viewable_and_light_viewable_from_file(
|
|
|
259
258
|
|
|
260
259
|
data = geode_functions.load(geode_object, copied_full_path)
|
|
261
260
|
|
|
262
|
-
# Remplacer :
|
|
263
|
-
# database.session.delete(temp_data_entry)
|
|
264
|
-
# database.session.flush()
|
|
265
|
-
# Par :
|
|
266
261
|
session = get_session()
|
|
267
262
|
if session:
|
|
268
263
|
session.delete(temp_data_entry)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenGeodeWeb-Back
|
|
3
|
-
Version: 5.10.
|
|
3
|
+
Version: 5.10.3rc1
|
|
4
4
|
Summary: OpenGeodeWeb-Back is an open source framework that proposes handy python functions and wrappers for the OpenGeode ecosystem
|
|
5
5
|
Author-email: Geode-solutions <team-web@geode-solutions.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Back
|
|
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: <3.13,>=3.9
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: asgiref~=3.
|
|
14
|
+
Requires-Dist: asgiref~=3.10
|
|
15
15
|
Requires-Dist: blinker~=1.9
|
|
16
16
|
Requires-Dist: click~=8.3
|
|
17
17
|
Requires-Dist: fastjsonschema~=2.21
|
|
@@ -32,7 +32,7 @@ Requires-Dist: opengeode-io==7.4.0
|
|
|
32
32
|
Requires-Dist: opengeodeweb-microservice>=1.0.3,~=1.0
|
|
33
33
|
Requires-Dist: sqlalchemy~=2.0
|
|
34
34
|
Requires-Dist: typing-extensions~=4.15
|
|
35
|
-
Requires-Dist: werkzeug
|
|
35
|
+
Requires-Dist: werkzeug==3.1.2
|
|
36
36
|
Dynamic: license-file
|
|
37
37
|
|
|
38
38
|
<h1 align="center">OpenGeodeWeb-Back<sup><i>by Geode-solutions</i></sup></h1>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
opengeodeweb_back/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
opengeodeweb_back/
|
|
2
|
+
opengeodeweb_back/app.py,sha256=HrEVaxrttrwkSvl7UVplwCY7SsqvXxz6r6srnPiVkl4,4518
|
|
3
|
+
opengeodeweb_back/app_config.py,sha256=z-omTiGj3-y0BZ1IchAM6EoTdC7vAX6B4OymEnuM0T4,843
|
|
3
4
|
opengeodeweb_back/geode_functions.py,sha256=NzELy9s6AETDnm7tyA_uM2N89zrfeLdblRhzYrBONmw,10804
|
|
4
5
|
opengeodeweb_back/geode_objects.py,sha256=_NclGPa024kCwUHdORkFuXYtiZBmQpgq6sO3LRkBhe8,27776
|
|
5
6
|
opengeodeweb_back/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
|
|
6
7
|
opengeodeweb_back/test_utils.py,sha256=18AbRW9-tfKkPcmRGilTTHXI7S3armYyV7Vdy5UvUKM,794
|
|
7
|
-
opengeodeweb_back/utils_functions.py,sha256=
|
|
8
|
+
opengeodeweb_back/utils_functions.py,sha256=A9xWWD0Zf9-XLR3k6WOQq9wvFtyjV3ceLtjjpx0dNZs,9071
|
|
8
9
|
opengeodeweb_back/routes/blueprint_routes.py,sha256=h_yfFC3ljH0KqFr5Ab_-IQYNB7VVRENwAMQk4NDsh18,11042
|
|
9
10
|
opengeodeweb_back/routes/models/blueprint_models.py,sha256=Jo9pUDeu1nO3_IbBiuHGk57cc4_fhwxjM0EKNyv1FT0,1874
|
|
10
11
|
opengeodeweb_back/routes/models/schemas/mesh_components.json,sha256=JmQUvpy7HpGS6FlThZLx1YjHqiInRTqUZ_Ft5MfOzEE,239
|
|
@@ -23,8 +24,9 @@ opengeodeweb_back/routes/schemas/save_viewable_file.json,sha256=pvvEdaC7bNASPMrl
|
|
|
23
24
|
opengeodeweb_back/routes/schemas/texture_coordinates.json,sha256=2uQueIl1jOmxFG_gIi_vJETR4IurrwuSf8GAnzphk9g,237
|
|
24
25
|
opengeodeweb_back/routes/schemas/upload_file.json,sha256=LJ3U3L5ApKuQDVFIpVT_y2alq4HW_suTvZ3HUucNbhg,219
|
|
25
26
|
opengeodeweb_back/routes/schemas/vertex_attribute_names.json,sha256=ECIflohiqPZNsflAdkfEzksL4we0JvZhIxUd84Ubctg,240
|
|
26
|
-
opengeodeweb_back-5.10.
|
|
27
|
-
opengeodeweb_back-5.10.
|
|
28
|
-
opengeodeweb_back-5.10.
|
|
29
|
-
opengeodeweb_back-5.10.
|
|
30
|
-
opengeodeweb_back-5.10.
|
|
27
|
+
opengeodeweb_back-5.10.3rc1.dist-info/licenses/LICENSE,sha256=LoTB-aqQvzTGxoTRXNnhNV0LKiqdk2bQv6MB34l8zkI,1079
|
|
28
|
+
opengeodeweb_back-5.10.3rc1.dist-info/METADATA,sha256=PDPJjeBw-RQm1Ny7txsWZaixJpcDCN6OKGdQvr9FMAw,2854
|
|
29
|
+
opengeodeweb_back-5.10.3rc1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
30
|
+
opengeodeweb_back-5.10.3rc1.dist-info/entry_points.txt,sha256=3W_t5GFc9ROHSIZ55IGvYU3DLHUFQmYOM4Bm9u3Z0cE,71
|
|
31
|
+
opengeodeweb_back-5.10.3rc1.dist-info/top_level.txt,sha256=tN1FZeLIVBrdja2-pbmhg5-tK-JILmmT9OeIBnhlUrQ,18
|
|
32
|
+
opengeodeweb_back-5.10.3rc1.dist-info/RECORD,,
|
|
File without changes
|
{opengeodeweb_back-5.10.2.dist-info → opengeodeweb_back-5.10.3rc1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|