-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up FastApi with hello world end point
- Loading branch information
Showing
10 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
__pycache__ | ||
*.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} |