rafaelpadilla / flask-school-app-and-api

Web app and REST API built with Flask

Home Page:https://flask-school-app.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Code Health

School App and API

This is a Flask app with an API layer. It has the following properties:

  1. It has the following relational entities:
    1. Student
    2. Teacher
    3. Subject
  2. Each student can have only one subject as a major, but can read any subject as well (minors)
  3. A subject is taught by one teacher
  4. It has endpoints to CREATE, UPDATE, and DELETE each entity in the application
  5. Only an authorized user can access the endpoints

Installation and Set Up

Clone the repo from GitHub:

git clone https://github.com/mbithenzomo/flask-student-api

Fetch from the develop branch:

git fetch origin develop

Navigate to the root folder:

cd flask-student-api

Install the required packages:

pip install -r requirements.txt

Create a .env file with the following keys:

SECRET_KEY
DATABASE_URI - for SQLAlchemy
TEST_DATABASE_URI - for SQLAlchemy
ENVIRONMENT - this is either production or development

Initialize, migrate, and upgrade the database:

python manage.py db init
python manage.py db migrate
python manage.py db upgrade

Launching the Program

Run python run.py. You may use Postman for Google Chrome to run the API.

API Endpoints

Resource URL Methods Description Requires Token
/api/v1 GET The index FALSE
/api/v1/auth/register POST User registration FALSE
/api/v1/auth/login POST User login FALSE
/api/v1/students GET, POST View all students, add a student TRUE
/api/v1/students/<string:id> GET, PUT, DELETE View, edit, and delete a single student TRUE
/api/v1/teachers GET, POST View all teachers, add a teacher TRUE
/api/v1/teachers/<string:id> GET, PUT, DELETE View, edit, and delete a single teacher TRUE
/api/v1/subjects GET, POST View all subjects, add a subject TRUE
/api/v1/subjects/<string:id> GET, PUT, DELETE View, edit, and delete a single subject TRUE

Sample API Requests

Registering and logging in to get a JWT token: User Registration

User Login

Displaying a paginated list of teachers: List of Teachers

Displaying a paginated list of subjects: List of Subjects

Updating a student: Updating Student

Web App

The app has a web-based interface and can be accessed here. A sample user has already been created with the following credentials:

username: testuser
password: testpassword

Login: User Login

Dashboard: App Dashboard

Displaying all students: Students

Displaying all teachers: Teachers

Displaying all subjects: Subjects

Testing

To test, run the following command: nose2

Built With...

Credits

Copyright (c) 2018 Mbithe Nzomo

About

Web app and REST API built with Flask

https://flask-school-app.herokuapp.com/


Languages

Language:JavaScript 41.7%Language:CSS 35.6%Language:Python 13.7%Language:HTML 8.9%Language:Mako 0.1%