Spaces:
No application file
No application file
Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from daytona import Daytona, DaytonaConfig
|
| 2 |
+
|
| 3 |
+
# Define the configuration
|
| 4 |
+
config = DaytonaConfig(api_key="dtn_700c66df2537fb90744e642bcbe3994129729e07708c449ddbd189b6294ba1dc")
|
| 5 |
+
|
| 6 |
+
# Initialize the Daytona client
|
| 7 |
+
daytona = Daytona(config)
|
| 8 |
+
|
| 9 |
+
# Create the Sandbox instance
|
| 10 |
+
sandbox = daytona.create()
|
| 11 |
+
|
| 12 |
+
# Run the code securely inside the Sandbox
|
| 13 |
+
response = sandbox.process.code_run('print("Hello World from code!")')
|
| 14 |
+
if response.exit_code != 0:
|
| 15 |
+
print(f"Error: {response.exit_code} {response.result}")
|
| 16 |
+
else:
|
| 17 |
+
print(response.result)
|