(data: Dict, func=func)
| 71 | |
| 72 | @app.post(f"/{func.get_function_name()}") |
| 73 | async def dynamic_function(data: Dict, func=func): |
| 74 | redirect_stdout = data.get('redirect_stdout', False) |
| 75 | if redirect_stdout: |
| 76 | sys.stdout = io.StringIO() |
| 77 | response_data = func.func(*data['args'], **data['kwargs']) |
| 78 | if redirect_stdout: |
| 79 | sys.stdout.seek(0) |
| 80 | output = sys.stdout.read() |
| 81 | sys.stdout = sys.__stdout__ |
| 82 | return { |
| 83 | "output": json.dumps(response_data), |
| 84 | "stdout": output, |
| 85 | } |
| 86 | return {"output": json.dumps(response_data)} |
| 87 | |
| 88 | except (ImportError, AttributeError) as e: |
| 89 | logger.error(f"Error importing {module_function}: {e}") |
nothing calls this directly
no outgoing calls
no test coverage detected