MCPcopy Index your code
hub / github.com/WebODM/WebODM / get_dynamic_script_handler

Function get_dynamic_script_handler

app/plugins/functions.py:312–328  ·  view source on GitHub ↗
(script_path, callback=None, **kwargs)

Source from the content-addressed store, hash-verified

310 return path_traversal_check(os.path.join(settings.MEDIA_ROOT, "plugins", *paths), os.path.join(settings.MEDIA_ROOT, "plugins"))
311
312def get_dynamic_script_handler(script_path, callback=None, **kwargs):
313 def handleRequest(request):
314 if callback is not None:
315 template_params = callback(request, **kwargs)
316 if not template_params:
317 return HttpResponse("")
318 else:
319 template_params = kwargs
320
321 with open(script_path) as f:
322 tmpl = Template(f.read())
323 try:
324 return HttpResponse(tmpl.substitute(template_params))
325 except TypeError as e:
326 return HttpResponse("Template substitution failed with params: {}. {}".format(str(template_params), e))
327
328 return handleRequest
329
330def enable_plugin(plugin_name):
331 p = get_plugin_by_name(plugin_name, only_active=False)

Callers 1

get_dynamic_scriptMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected