Skip to content

This repository hosts the code, issues and tasks related to the deployment of web-based applications to receive and serve user requests for LCA calculations.

License

Notifications You must be signed in to change notification settings

BONSAMURAIS/bonsai_web_api

Bonsai Web API

What is it?

This is a basic Flask app on which to build the different web-based modules for Bonsai.

We foresee four inter-related applications:

  • a web application that handles interactions with users (requests for graphs, sessions, login, etc.)
  • a REST API that serves both the web application and direct REST requests on one side, and queries the graph DB on the other side,
  • a module that receive the whole graph database at server start, converts it into a two dimensional matrix and cache it for ulterior requests,
  • and a module that calculates LCA results upon requests from the REST API.

We do not yet have a working DB to receive triplestore queries from. However, we can use a dummy one in the meanwhile.

alt text

Install

Clone the repository

git clone https://github.com/BONSAMURAIS/bonsai_web_api

Create a virtual environment and activate it

python3 -m venv venv
. venv/bin/activate

Or on Windows cmd

py -3 -m venv venv
venv\Scripts\activate.bat

Install bonsai_web_api

pip install -e .

Or if you are using the master branch, install Flask from source before installing bonsai_web_api

pip install -e ../..
pip install -e .

Run

Docker

The application can be run as a doker container. Build the image first with:

docker build -t bonsai_web_api .

and then run it with:

docker run --rm -it --name bonsai_web_api -p 5000:5000 bonsai_web_api:latest

Native

Set the environment variables

export FLASK_APP=bonsai_web_api
export FLASK_ENV=development

Initalize the databases if first use

flask init-db

Run local server

flask run

Or on Windows cmd

set FLASK_APP=bonsai_web_api
set FLASK_ENV=development
flask init-db
flask run

Open http://127.0.0.1:5000 in a browser.

Test

pip install '.[test]'
pytest -v

Run with coverage report

coverage run -m pytest
coverage report
coverage html  # open htmlcov/index.html in a browser

About

This repository hosts the code, issues and tasks related to the deployment of web-based applications to receive and serve user requests for LCA calculations.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •