Open om-tericsoft1 opened 1 month ago
@om-tericsoft1 Can you share the E2B SDK code you are using for running your project and how you are accessing the API endpoints?
@ValentaTomas here is a sample code.
async def py_hosting_app(code,prisma):
sandbox = Sandbox(template="base", timeout=300,api_key=E2B_API_KEY)
# Run these I/O-bound operations asynchronously
await asyncio.to_thread(sandbox.filesystem.write, "/home/user/main.py", code)
await asyncio.to_thread(sandbox.filesystem.write, "/home/user/prisma.schema", prisma)
result = sandbox.process.start("pip install fastapi uvicorn prisma fastapi-cors")
result.wait()
print(result.stdout)
result = sandbox.process.start("prisma migrate --schema=/home/user/prisma.schema")
result.wait()
print(result.stdout)
result = sandbox.process.start("prisma generate --schema=/home/user/prisma.schema")
result.wait()
print(result.stdout)
print(result.stderr)
await asyncio.to_thread(sandbox.process.start, "uvicorn main:app --reload")
# Get the URL
url = sandbox.get_hostname(8000)
print(f"node app is running at: https://{url}")
return url
I have integrated Swagger APIs into my project running in the e2b sandbox environment, but they are not functioning as expected. The Swagger UI loads correctly, but the API endpoints are either unresponsive or return unexpected errors. I have tested the same APIs outside of the e2b environment, and they work without any issues.