Eclipse Che: Unable to expose the endpoint to accessibly url for the sample hello world application using python workspace
Summary
I using supplied python workspace ("python Hello world") and trying to create hello world application. Here is my code: pip install "fastapi[all]" Python Code : from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"} Then run application with below command: uvicorn main:app --reload
The application is exposed to 127.0.0.0 i.e locally. I modified the devfile as below -- added the exposure directives....
container: image: quay.io/devfile/universal-developer-image:ubi8-latest endpoints: - exposure: public name: 8080-tcp protocol: http targetPort: 8080
But no luck. Any clue pls
Relevant information
No response
When you run the application in your workspace, you should see a toast notification in the lower right corner of the window prompting you to forward the port to make it accessible from outside of your workspace:
Clicking "yes" on this dialog will allow you to open the running application in a new tab within your browser.
Some other things worth noting:
- By default, this application will listen on 127.0.0.1 and port 8000, but your configured endpoint references port 8080. To fix this, you need to replace
targetPortin your endpoint with8000(optionally, update the name of the endpoint as well) - If you want to avoid the toast notification, configure your application to listen on 0.0.0.0 instead. To fix this, run
uvicorn main:app --reload --host 0.0.0.0. The reason this is required is that 127.0.0.1 is localhost within the container, and so not accessible from outside that container. - Once you figure out a set up that works, it may also be worth adding a devfile command in order to enable running the application with one click.
Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.
Mark the issue as fresh with /remove-lifecycle stale in a new comment.
If this issue is safe to close now please do so.
Moderators: Add lifecycle/frozen label to avoid stale mode.