/mowa-backend-flask

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

mowa-backend-flask

The project provides MoWA back-end framework and front-end framework services


🌎 README.md in English
🇰🇷 README.md in Korean


Content

Getting Started

Installing

  1. Clone the project repository

    git https://github.com/oss-inc/mowa-backend-flask
  2. Python Virtual Environment Setup

    conda create -n mowa-backend-flask python=3.8
  3. Installing the Flask Server

    pip install -r requirements.txt

Usage

Execution Program

  1. Run app.py for Flask Server(Back-end)

    python -m flask run 
  2. Run app.services.dashboard.py for Management page (Front-end)

    python -m app.services.dashboard run

Configuration

  1. Database setting with app/databases/db_info.json

    {
      "Database": {
        "host": "DATABASE_IP",
        "user": "USER_NAME",
        "password": "USER_PASSWORD!",
        "database": "DATABASE_NAME"
      }
    }
  2. Server Host and Port setting in __init__.py

    if __name__ == '__main__':
        app.run(debug=True, host='0.0.0.0', port=8000)

    You can change host IP and port number
    The IP default is 0.0.0.0 and the port default is 8000.

  3. Web page Host and Port setting in app.services.dashboard.py

    if __name__ == '__main__':
        server.run(debug=True, host="0.0.0.0", port=8050)

    You can change host IP and port number
    The IP default is 0.0.0.0 and the port default is 8050.

  4. Database setting with mysql query

    SQL Code
    create table users
    (
        id       int auto_increment
            primary key,
        name     varchar(255) not null,
        email    varchar(255) not null,
        password varchar(255) not null,
        constraint email
            unique (email)
    );
    
    create table activity
    (
        id             int          not null,
        email          varchar(255) not null,
        date           date         not null,
        warning_count  int          null,
        activity_count int          null,
        fall_count     int          null,
        primary key (id, date, email),
        constraint activity_ibfk_1
            foreign key (id) references users (id)
                on update cascade on delete cascade,
        constraint activity_ibfk_2
            foreign key (email) references users (email)
                on update cascade on delete cascade
    );
    
    create table profile
    (
        id    int          not null
            primary key,
        email varchar(255) null,
        src   varchar(255) null,
        constraint profile_ibfk_1
            foreign key (id) references users (id)
                on update cascade on delete cascade,
        constraint profile_ibfk_2
            foreign key (email) references users (email)
                on update cascade on delete cascade
    );
  5. Change Request URL in app.services.controller.callback.py

    if tab == 'user-tab-1':
          response = requests.get("http://{ServerIP}:{ServerPort}/user/users")
          return response.json()

    If you are going to use the dashboard, you should change to server IP and server port.

Demo

Back-end (Flask)

1. User API

swagger_1.png

2. Activity API

swagger_2.png

3. Model

swagger_3.png

Front-end (Dash)

1. User Management

dashboard_1.png dashboard_2.png dashboard_3.png dashboard_4.png

2. User Statistics

dashboard_5.png dashboard_6.png

License

This project is licensed under the MIT License - see the LICENSE.md file for details