2. Run API Server Locally¶
This runs a preview version of the API server locally, with hot reload, for rapid iteration.
1. Run FastAPI Dev Server¶
-
Run this command from the root of the repo, in the Visual Studio Code terminal:
Bash 1fastapi dev src/api/main.py -
Verify that this starts a development server
- You should see: a pop-up dialog with two options to view the application
- Select the "Browser" option - should open the preview in a new browser tab
- Check the browser URL - should be a path ending in
github.dev - Check the page content - should show the "Hello World" message
2. Connect the Dots! 💡¶
-
The
github.devending validates the server is hosted by GitHub Codespaces- This verifies we are running in the (local) dev environment.
- When deployed to production, you'll see
containerapps.io(for ACA).
-
What just happened?
- The dev server ran the
main.pydefined application with 2 routes - The default route
/returns the "Hello world" message (see line 46) - This confirms that our application server is running successfully.
- The dev server ran the
CONGRATULATIONS. You just ran the FastAPI app and tested its default endpoint