Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i use swagger API's from E2b sandbox ? #455

Open
om-tericsoft1 opened this issue Oct 9, 2024 · 3 comments
Open

How can i use swagger API's from E2b sandbox ? #455

om-tericsoft1 opened this issue Oct 9, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@om-tericsoft1
Copy link

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.

@om-tericsoft1 om-tericsoft1 added the feature New feature or request label Oct 9, 2024
Copy link

linear bot commented Oct 9, 2024

@ValentaTomas ValentaTomas added bug Something isn't working and removed feature New feature or request labels Oct 9, 2024
@ValentaTomas
Copy link
Member

@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 ValentaTomas self-assigned this Oct 19, 2024
@om-tericsoft1
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants