Skip to content

ai-cfia/fertiscan-backend

Repository files navigation

fertiscan-backend

A flask-based backend for FertiScan.

Setup for Development

Prerequisites

  • Python 3.8 or higher
  • pip
  • virtualenv
  • Azure Document Intelligence and OpenAI API keys

Running

Locally

cd fertiscan-backend
pip install -r requirements.txt
python ./app.py

With docker

  1. Build the docker image

    docker build -t fertiscan-backend \
    --build-arg ARG_AZURE_API_ENDPOINT=your_actual_azure_form_recognizer_endpoint \
    --build-arg ARG_AZURE_API_KEY=your_actual_azure_form_recognizer_key \
    --build-arg ARG_AZURE_OPENAI_API_ENDPOINT=your_actual_azure_openai_endpoint \
    --build-arg ARG_AZURE_OPENAI_API_KEY=your_actual_azure_openai_key \
    --build-arg ARG_PROMPT_PATH=actual_path/to/prompt_file \
    --build-arg ARG_UPLOAD_PATH=actual_path/to/upload_file \
    --build-arg ARG_FRONTEND_URL=http://url.to_frontend/ \
    .
  2. Run the docker image

    docker run -p 5000:5000 fertiscan-backend
  3. Test the application

Go to http://localhost:5000 and test the application.

With docker-compose

Coming soon...

Environment Variables

Create a .env file in the root directory from .env.template:

AZURE_API_ENDPOINT=your_azure_form_recognizer_endpoint
AZURE_API_KEY=your_azure_form_recognizer_key
AZURE_OPENAI_API_ENDPOINT=your_azure_openai_endpoint
AZURE_OPENAI_API_KEY=your_azure_openai_key

PROMPT_PATH=path/to/file
UPLOAD_PATH=path/to/file
FRONTEND_URL=http://url.to_frontend/

API Endpoints

  • POST /analyze: Analyze the images and returns the form.