This project is a RESTful API built with Python and FastAPI.
- Clone the repository
git clone https://github.com/suvarnakd/fast-api-hw.git
- Create a Python 3.9 virtual environment:
python3.9 -m venv venv
- Activate the env
source venv/bin/activate
- Install requirements
pip install -r requirements.txt
Run the API with uvicorn:
uvicorn app.main:app --reload
- Any AI code implemented with fast-api can be deployed on gcp with app engine deployment.
- The gcloud app command group lets you deploy and manage your Google App Engine apps.
- Steps:
- Create/seclect the gcp project https://console.cloud.google.com/
- Select APIs & Services
- Select the "Activate cloud shell"
>-
- Make sure that you have the correct current project
gcloud config list project
- Clone the repository
git clone https://github.com/suvarnakd/fast-api-hw.git
cd fast-api-hw
- You may directly deploy your app, or you may check if everything works by manually trying to run the api on VM provided with console
virtualenv env
source env/bin/activate
pip install -r requirements.txt
gunicorn -k uvicorn.workers.UvicornWorker app.main:app
If you could run this successfully, your requirements.txt has all required libraries to host fastapi code.
- you may stop the running process and check the app.yaml file
cat app.yaml
- To see the apps already deployed on app engine use following-
gcloud app browse
- To deploy our current hello world api app
fast-api-hw
gcloud app deploy
- to see tha log of deployment
gcloud app logs tail -s default
- You may see a url if the app is deployed correctly
gcloud app browse
-
Visit the url for example https://auto-annotation-demo.as.r.appspot.com to access the deployed API.
-
If there are any changes in the repo, simply pull the changes and reploy the app with
gcloud app deploy