Skip to content

Latest commit

 

History

History
37 lines (20 loc) · 1.67 KB

README.md

File metadata and controls

37 lines (20 loc) · 1.67 KB

egrid-server

Rest API for the EPA's Emissions & Generation Resource Integrated Database

Supports searching by Geolocation (latitude / longitude) via GeoDjango / PostGIS

Currently using 2020 data, new 2021 data was just released and will be supported soon

Usage

  1. /api/plants serves up a paginated list of all the plants in the database
  2. /api/plants/?lat=LAT&lng=LNG&rad=DIST the plants endpoint supports query parameters for finding all plants within a radius of a latlong point

Building

  1. pip install -r requirements.txt

This app was built/tested with Python 3.11.1

Running the server

This app was built to deploy to Fly.io

  1. Install PostGIS or run a docker image of it, taking note of any password you set on it.
    1. If you installed PostGIS, don't forget to run the CREATE EXTENSION SQL statements on the database enable PostGIS
    2. If you're deploying to Fly.io, you'll need to connect to the database to run these extensions
  2. Set Environmental Variables
    1. EGRID_SERVER_DJANGO_SECRET_KEY – used by Django to encrypt session keys
    2. DATABASE_URL – used by Django to find and connect to the PostGIS backend. Fly.io will set this environment variable automatically when you run fly launch and setup a postgres database. For details on the URL format, see the dj-database-url docs
  3. python manage.py migrate to run migrations and populate the database with the Egrid database
  4. python manage.py runserver to start the server