Skip to content

A simple but general Flask API for uploading csv files to a database and viewing, made during my internship at AgroFides

Notifications You must be signed in to change notification settings

jsmith2021Brandeis/Agronomic_Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AgroFides Bare Bones API

This repository contains the minimum necessary code to create a web server, update it using a python script, and retrieve information with a GET request.

Dev Setup

Clone Repo and build Docker containers

  1. Clone repo git clone [email protected]:agrofides/bare-bones-api.git and cd into the project
  2. Run docker-compose build to build the docker containers
  3. Run docker-compose up to launch the containers

Initialize DB and import schema

  1. In a new terminal run docker-compose exec api flask db init to create a new database migration repository

  2. Run docker-compose exec api flask db migrate to create a new revision

  3. Run docker-compose exec api flask db upgrade to persist the newly created revision

Create Roles

  1. Run docker-compose exec api python -m app.bin.setup_roles.
  2. Also change the enabled fields on line 24 and do 1 again to show update functionality

Get Roles

  1. Go to http://localhost:5000/roles to see the created roles

    Created Roles

    Other Operations

    Close Server

    ​ Ctrl+c in flask window

    Delete Database

     1. Build docker containers
     2. `docker-compose exec api python -m app.bin.nukedb`
     3. Initialize DB and import schema
    

    Key Files

    app/models.py

    ​ Defined schema for database entry, in this case user accounts

    app/bin/setuproles.py

    ​ Script to populate database with user roles entries

    app/routes/main_routes.py

    ​ contains welcome page, error page, and get user roles pages (all and by role id)

Jacob Smith for AgroFides, Winter 2021

About

A simple but general Flask API for uploading csv files to a database and viewing, made during my internship at AgroFides

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published