This application provides a Flask-based API that can be run locally or deployed in a Google Cloud environment. Below are step-by-step instructions on installing dependencies, configuring Google Cloud, running the application, and testing the API locally.
- Python 3 (for running the Flask application)
- Google Cloud SDK (for Google Cloud integration)
- curl (for API testing)
- Clone or open the repository.
- Ensure you have installed Python dependencies (if applicable, use
pip install -r requirements.txt
). - Run the application:
python main.py
This starts the application at http://localhost:8000
.
Use the steps below on a Linux x86_64 machine:
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-linux-x86_64.tar.gz
tar -xf google-cloud-cli-linux-x86_64.tar.gz
./google-cloud-sdk/install.sh
Opt Yes to add sdk path to rc and Open a new terminal shell
Initialize the SDK:
gcloud init
Follow the prompts to choose your Google Cloud project and configure default settings.
Authenticate using Application Default Credentials:
gcloud auth application-default login
Follow the sign-in process in your browser, and your credentials will be saved locally.
You may need to grant specific permissions, for example:
gcloud projects add-iam-policy-binding law-ai-437009 \
--member=serviceAccount:[email protected] \
--role=roles/cloudbuild.builds.builder
Set your preferred default compute region and zone:
gcloud config set compute/zone asia-south1-a
gcloud config set compute/region asia-south1
Once the app is running on http://localhost:8080
, you can test an endpoint with curl
, for example:
curl --location 'http://localhost:8080/ask' \
--header 'Content-Type: application/json' \
--data '{"question":"What are the rights I have as a citizen of India?"}'
You should receive a JSON response containing the answer from your service.
- Check the generated
.boto
file if you plan to interact with Google Cloud Storage. - Your credentials are stored at
~/.config/gcloud/application_default_credentials.json
. - Ensure you have billing enabled on the selected project if you use any paid Google Cloud services.