This guide will help you set up ngrok and run your FastAPI server using a Conda environment.
Ensure you have the following installed:
- Conda (Anaconda/Miniconda)
- ngrok
- FastAPI and Uvicorn installed in your Conda environment
First, create an external tunnel using ngrok:
ngrok http --url=working-epic-dodo.ngrok-free.app 8000 --region ap
--url=working-epic-dodo.ngrok-free.app
: Custom ngrok URL to access your server.8000
: The local port where FastAPI will run.--region ap
: Specify the region (Asia Pacific).
Keep this terminal window open as ngrok will run continuously to tunnel your FastAPI server.
In a new terminal, activate the Conda environment where FastAPI and Uvicorn are installed:
conda activate kekeluargaan
Now, run your FastAPI server using uvicorn:
uvicorn app:app --reload
This will start the server locally on http://127.0.0.1:8000
, which is now accessible via the ngrok URL.
Visit your FastAPI documentation by navigating to:
https://working-epic-dodo.ngrok-free.app/docs
Your FastAPI server is now publicly accessible via the ngrok tunnel.
Make sure to keep both terminal windows (ngrok and FastAPI server) open while you're working on your project. The ngrok URL will change if you restart the ngrok process, so update your access URL accordingly.
- For more information on ngrok, visit ngrok documentation.
- To learn more about FastAPI, check out the FastAPI documentation.
- For Conda environment management, refer to the Conda documentation.