Giter Site home page Giter Site logo

circularwood_4.0_wp1's Introduction

Wood Database REST API

master branch

This repository contains the work files of API written for the CW4.0 Research project in HVA Robot Lab

For the CW4.0 work package one, the goal was to create a database of residual wood that can store information from the wood. In order to develop the application, Flask is used. Flask is relatively easy and quick to start framework, but if the goal is to scale this application up, it's probably better to enable concurrency and for that we can use a different frameworks like Fast API or Django.

Contact

Wood Database REST API

The API resources for wood and tagging of wood. The full documentation of the API endpoints are available at the api-docs accessing is through: http://localhost/api-docs for development server and https://robotlab-residualwood.onrender.com/api-docs for the production server

Quick Start

In order to run the server for development, you can either download all required libraries and run the app.py file or run the Docker container (which is recommended)

Running the app.py file

If you opt to run the app.py file after installing all the requirements, you need to change the end line from return app to the following statement:

if __name__ == '__main__':
    db.init_app(app)
    app.run(port=5000, debug=True)

this way you make sure that the application is executed and the database is initialized.

Running the Application with Docker

If you are using Windows or Mac, Install Docker via downloading and installing Docker Desktop

In order to run this api for development, please create a Docker image and run the app in the container.

Running the application in the Docker container can be done via two ways in this project via Dockerfile or docker-compose command. Following is the instructions for both ways.

1. Docker via Dockerfile

Create a docker image

docker build --no-cache -t image_name .

Run the Dockerfile locally

docker run -dp 5000:5000 -w /app
 -v "/c/Users/username/directory/project_folder/project_name:/app" image_name

2. Docker via docker-compose

Run the Docker via docker-compose (simpler method)

There is a docker-compose.yml file in the project root that can be used to create the image and container via the following command

docker-compose up -d

Remove the docker container via docker-compose

docker-compose down

Testing the API

For testing the API during development, you can use different tools such as Postman or Insomnia. I used Insomnia. You can find an exported collection of requests inside the insomnia directory in the project src. Once you installed Insomnia, you can import the collection of the requests.

Here is the download link: https://insomnia.rest/download

Setting up the Insomnia profile

Once you downloaded and run the Insomnia app, now it's time to import the collection of requests for all the endpoints registered in the API.

There is an exported collection available to get you started. You can find the JSON file that is basically the collection of the 'HTTP' requests inside the ./insomnia directory. You need to import this JSON file inside the Insomnia to load the API requests collection. After that, you would need to proceed with setting the environment variables such as url, access_token in Insomnia.

You can google and check the documentations of the Insomnia to do it. but basically you would need to set the environment variables like this as example:

{
    "url": "http://localhost:5000",
    "access_token": <The access_token from the JWT>
}

Contributing to the API

please check the CONTRIBUTING.md document

circularwood_4.0_wp1's People

Contributors

flabelatus avatar

Stargazers

 avatar

Watchers

 avatar

circularwood_4.0_wp1's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.