Skip to content

Repository files navigation

RebuildLA Flask API

A Flask-based API server with endpoints for disaster recovery assistance:

  • /api/stayhealthy - Health information API
  • /api/replacedocs - Document replacement services
  • /api/debrisremove - Debris removal requests
  • /api/getshelter - Find nearest shelters with availability

Setup

Prerequisites

  • Python 3.7+
  • Weaviate vector database (local or cloud instance)

Installation

  1. Create a virtual environment (optional but recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Set up Weaviate:

    • For local development, you can run Weaviate using Docker:
      docker run -d -p 8080:8080 --name weaviate-server semitechnologies/weaviate:1.17.2
      
    • Alternatively, use a cloud Weaviate instance and set the WEAVIATE_URL and WEAVIATE_API_KEY environment variables
  4. Initialize the Weaviate schema and load sample data:

    python weaviate_schema.py
    python populate_shelters.py
    
  5. Run the server:

    python app.py
    

The server will start on http://localhost:6000.

API Endpoints

All base endpoints accept both GET and POST methods and return a simple JSON message.

Shelter Finder API

Endpoint: /api/getshelter

Find the nearest shelter based on your address and specific needs.

Request Format (POST):

{
  "address": "123 Main St, Los Angeles, CA 90012",
  "query": "I need a shelter that accepts pets and has medical services"
}

Response Format:

{
  "shelters": [
    {
      "name": "Valley Veterans Shelter",
      "address": "321 Sherman Way, Van Nuys, CA 91405",
      "distance": "4.2 miles",
      "phone": "818-555-7890",
      "website": "https://www.valleyveteransshelter.org",
      "capacity": "35/60",
      "services": ["VA benefits assistance", "PTSD counseling", "Job placement", "Housing navigation"],
      "accepts_pets": true,
      "hours": "24/7",
      "description": "Specialized shelter for veterans with PTSD support and VA services coordination"
    },
    {
      "name": "Downtown Emergency Shelter",
      "address": "123 Main Street, Los Angeles, CA 90012",
      "distance": "5.1 miles",
      "phone": "213-555-1234",
      "website": "https://www.downtownshelter.org",
      "capacity": "85/150",
      "services": ["Medical care", "Meals", "Case management", "Mental health services"],
      "accepts_pets": false,
      "hours": "24/7",
      "description": "Large capacity emergency shelter located in downtown LA with medical facilities and 24/7 staff"
    }
  ],
  "count": 2,
  "user_address": "123 Main St, Los Angeles, CA 90012"
}

Environment Variables

  • WEAVIATE_URL: URL of your Weaviate instance (default: http://localhost:8080)

  • WEAVIATE_API_KEY: API key for authenticated Weaviate access (optional for local instances)

  • Stay Healthy API: /api/stayhealthy

  • Replace Docs API: /api/replacedocs

  • Debris Remove API: /api/debrisremove

You can test the API using tools like curl, Postman, or simply through your browser (for GET requests).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages