Fixes in urls

This commit is contained in:
Antonio de la Rosa 2020-01-17 00:43:06 +01:00
parent 4a67d7b189
commit e0ed00af8c
3 changed files with 26 additions and 9 deletions

View file

@ -3,6 +3,7 @@ from settings import config
from importlib import import_module
import os
import sys
import inspect
def start_app():
@ -20,19 +21,27 @@ def start_app():
APPLICATION_ROOT=application_root
)
workdir=os.getcwd()
arr_module_path={}
# Load blueprints
for added_app in config.apps:
a=import_module(added_app)
#print(added_app, file=sys.stdout)
app_name=getattr(a, config.apps[added_app][0])
module_app=config.apps[added_app][0]
app.register_blueprint(app_name)
a=import_module(module_app)
#print(added_app, file=sys.stdout)
app_name=getattr(a, config.apps[added_app][1])
app.register_blueprint(app_name, url_prefix=config.apps[added_app][2])
arr_module_path[added_app]=os.path.dirname(sys.modules[module_app].__file__)
#Add media files support. Only for development.
workdir=os.getcwd()
#print(inspect.getmembers(sys.modules['paramecio2.modules.admin.app']))
#print(os.path.dirname(sys.modules['paramecio2.modules.admin.app'].__file__))
@app.route('/mediafrom/<module>/<path:media_file>')
def send_media_file(module, media_file):
@ -40,7 +49,8 @@ def start_app():
file_path=workdir+'/themes/'+config.theme+'/media/'+module+'/'+media_file
if not os.path.isfile(file_path):
file_path=workdir+'/modules/'+module+'/media/'+media_file
#file_path=workdir+'/modules/'+module+'/media/'+media_file
file_path=arr_module_path[module]+'/media/'+media_file
if not os.path.isfile(file_path):
abort(404)