Skip to content
Snippets Groups Projects
Benedikt Seeger's avatar
Benedikt authored
9189d32f
History

Content

This repo contains a Bokeh application that allows to validate D-SI unit parsing and conversion by the dsiUnit Module

The Web Gui Looks Like: Gui SHowing two unit inputs and a coparison triabngle

Install localy

git clone https://gitlab1.ptb.de/digitaldynamicmeasurement/dsi-parser-frontend.git
cd dsi-parser-frontend
pip install -r requirements.txt

Run the Bokeh Server

bokeh serve ./ --port 5020

Run the rest API

Use Docker Container

docker pull benesee/dsiunitsfrontend:latest
docker run -p 5020:5020 benesee/dsiunitsfrontend:latest

Creating comprehensive API documentation for your FastAPI application helps users understand how to interact with your endpoints effectively. Below is a markdown format that you can use for your README file or any other documentation platform. This example includes descriptions of the endpoints, expected inputs, and outputs based on the FastAPI code you provided.


API Documentation for Unit Conversion Service

This documentation covers the available REST API endpoints for converting unit strings to UTF-8 and LaTeX formats, as well as comparing different units for scalability and conversion. Each endpoint is described with its functionality, required input, and example responses.

Endpoints

Convert to UTF-8

  • URL: /convert/utf8/
  • Method: POST
  • Description: Converts a unit string to its UTF-8 representation.
  • Request Body:
    {
      "unit_string": "String"
    }
  • Responses:
    • 200 OK:
      {
        "utf8_string": "Converted UTF-8 string"
      }
    • 500 Internal Server Error:
      {
        "detail": "Error message"
      }

Convert to LaTeX

  • URL: /convert/latex/
  • Method: POST
  • Description: Converts a unit string to its LaTeX representation.
  • Request Body:
    {
      "unit_string": "String"
    }
  • Responses:
    • 200 OK:
      {
        "latex_string": "Converted LaTeX string"
      }
    • 500 Internal Server Error:
      {
        "detail": "Error message"
      }

Compare Units

  • URL: /compare/units/
  • Method: POST
  • Description: Compares two unit strings for scalability and equivalence. Optionally performs a complete conversion comparison if specified.
  • Request Body:
    {
      "unit_string1": "First unit string",
      "unit_string2": "Second unit string",
      "complete": false
    }
  • Responses:
    • 200 OK:
      {
        "scale_factor": "Scale factor if units are scalable",
        "base_unit": "Base unit derived from comparison"
      }
    • 400 Bad Request:
      {
      "detail": "Warnings or error details from unit validation"
      }
    • 500 Internal Server Error:
      {
        "detail": "Error message"
      }

Error Handling

Errors are returned as standard HTTP response codes along with a JSON body specifying the detail of the error.

  • 400 Bad Request: Sent when there's a validation error with the input data.
  • 500 Internal Server Error: Sent when the server encounters an unexpected condition.

Example Usage

Here's an example using curl to make a request to the /convert/utf8/ endpoint:

curl -X POST "http://localhost:8000/convert/utf8/" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"unit_string\":\"\\meter\"}"