|
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
<title>Jupyter Kernel Execution API</title> |
|
<style> |
|
body { |
|
font-family: Arial, sans-serif; |
|
line-height: 1.6; |
|
color: #333; |
|
max-width: 800px; |
|
margin: 0 auto; |
|
padding: 20px; |
|
} |
|
h1 { |
|
color: #2c3e50; |
|
} |
|
h2 { |
|
color: #34495e; |
|
} |
|
pre { |
|
background-color: #f4f4f4; |
|
border: 1px solid #ddd; |
|
border-radius: 4px; |
|
padding: 15px; |
|
overflow-x: auto; |
|
} |
|
code { |
|
font-family: 'Courier New', Courier, monospace; |
|
} |
|
</style> |
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css" rel="stylesheet" /> |
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script> |
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script> |
|
|
|
</head> |
|
<body> |
|
<h1>Jupyter Kernel Execution API</h1> |
|
|
|
<p>This Flask application provides an API for executing Python code in a Jupyter kernel, with endpoints for code execution, kernel restart, and health checks.</p> |
|
|
|
<h2>Key Features</h2> |
|
<ul> |
|
<li>Execute Python code via HTTP POST request</li> |
|
<li>Timeout mechanism to prevent long-running code</li> |
|
<li>Error handling for various scenarios</li> |
|
<li>Support for displaying figures and handling output streams</li> |
|
<li>Kernel restart functionality</li> |
|
<li>Health check endpoint</li> |
|
</ul> |
|
|
|
<h2>Endpoints</h2> |
|
<h3>Execution Endpoint</h3> |
|
<pre><code class="language-python">import requests |
|
|
|
url = "https://lvwerra-executor.hf.space/execute" |
|
|
|
print(requests.post(url, json={'code': 'x=10'}).json()) |
|
print(requests.post(url, json={'code': 'y=20'}).json()) |
|
print(requests.post(url, json={'code': 'print(y*x)'}).json())</code></pre> |
|
|
|
<h3>Kernel Restart Endpoint</h3> |
|
<pre><code class="language-python">url = "https://lvwerra-executor.hf.space/restart" |
|
print(requests.post(url).json())</code></pre> |
|
|
|
<h3>Health Check Endpoint</h3> |
|
<pre><code class="language-python">url = "https://lvwerra-executor.hf.space/health" |
|
print(requests.get(url).json())</code></pre> |
|
</body> |
|
</html> |