Skip to content

Commit

Permalink
Set up FastApi with hello world end point
Browse files Browse the repository at this point in the history
  • Loading branch information
tsundvoll committed Jan 12, 2022
1 parent d741483 commit 459bf46
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Flotilla

Flotilla is the main point of access for operators to interact with multiple robots in a facility. The application consists of a [frontend](frontend/README.md) in React and a [backend](backend/README.md) in Python using the FastAPI framework.

## Setup

For development, please fork the repository. Then, clone the repository:
Expand Down
2 changes: 2 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__
*.egg-info
21 changes: 21 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Flotilla backend

## Installation
```bash
pip install -e .[dev]
```

## Running the API
Start the API by running
```bash
uvicorn flotilla.main:app --reload
```

The API is then available on
http://127.0.0.1:8000/docs

## Running the tests
The tests can be run with
```bash
pytest
```
6 changes: 6 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
]
build-backend = "setuptools.build_meta"
21 changes: 21 additions & 0 deletions backend/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool:isort]
line_length = 88
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True

[mypy]
follow_imports = normal
no_strict_optional = True
no_site_packages = True
ignore_missing_imports = True


[tool:pytest]
python_files = test_*.py
python_classes = Test
python_functions = test* test_*
testpaths = tests
log_cli = true
norecursedirs = integration
33 changes: 33 additions & 0 deletions backend/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from setuptools import find_packages, setup

setup(
name="flotilla",
version='0.0.0',
description="Backend for the Flotilla application",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Equinor ASA",
author_email="fg_robots_dev@equinor.com",
url="https://github.com/equinor/flotilla",
packages=find_packages(where="src"),
package_dir={"": "src"},
classifiers=[
"Environment :: Other Environment",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
],
include_package_data=True,
install_requires=[
"fastapi",
"uvicorn",
"requests",
],
extras_require={
"dev": [
"pytest",
]
},
python_requires=">=3.9",
)
Empty file.
7 changes: 7 additions & 0 deletions backend/src/flotilla/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def root():
return {"message": "Hello World"}
Empty file added backend/tests/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions backend/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from fastapi.testclient import TestClient

from flotilla.main import app

client = TestClient(app)


def test_main():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello World"}

0 comments on commit 459bf46

Please sign in to comment.