Skip to content

Commit 725814e

Browse files
5. FastAPI setup
1 parent cc63480 commit 725814e

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
bin/
2+
etc/
3+
share/
4+
15
# Byte-compiled / optimized / DLL files
26
__pycache__/
37
*.py[cod]

jupyter-api.code-workspace

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {}
8+
}

pyvenv.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
home = /Library/Frameworks/Python.framework/Versions/3.9/bin
2+
include-system-site-packages = false
3+
version = 3.9.2

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
jupyter==1.0.0
22
fastapi==0.63.0
3-
papermill==2.3.3
3+
papermill==2.3.3
4+
uvicorn

src/server.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import inspect
2+
import pathlib
3+
4+
from fastapi import FastAPI
5+
6+
filename = inspect.getframeinfo(inspect.currentframe()).filename
7+
BASE_DIR = pathlib.Path(filename).resolve().parent
8+
9+
app = FastAPI()
10+
11+
@app.get("/") # HTTP GET
12+
def read_root():
13+
return {"hello": "world", "parent": str(BASE_DIR)}
14+
15+
# @app.post('/') # HTTP POST
16+
# def write_root():
17+
# return {"hello": "world", "parent": str(BASE_DIR)}

0 commit comments

Comments
 (0)