Duplicate from dog/fastapi-hello-world
Browse filesCo-authored-by: Dr. President Admiral Roar Dreezy <[email protected]>
- .gitattributes +34 -0
- Dockerfile +11 -0
- README.md +11 -0
- app.py +20 -0
- index.html +52 -0
- requirements.txt +3 -0
.gitattributes
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
WORKDIR /code
|
4 |
+
|
5 |
+
COPY ./requirements.txt /code/requirements.txt
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
+
|
9 |
+
COPY . .
|
10 |
+
|
11 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: Fastapi Hello World
|
3 |
+
emoji: 📉
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: green
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
duplicated_from: dog/fastapi-hello-world
|
9 |
+
---
|
10 |
+
|
11 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from fastapi.responses import HTMLResponse
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
|
7 |
+
@app.get("/")
|
8 |
+
def home():
|
9 |
+
html_content = open('index.html').read()
|
10 |
+
return HTMLResponse(content=html_content, status_code=200)
|
11 |
+
|
12 |
+
|
13 |
+
@app.get("/hello")
|
14 |
+
def hello():
|
15 |
+
return {"hello": "world"}
|
16 |
+
|
17 |
+
|
18 |
+
@app.get("/hello/{name}")
|
19 |
+
def greet(name):
|
20 |
+
return {"greeting": f"Hello {name}!"}
|
index.html
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<!-- Title -->
|
3 |
+
<head>
|
4 |
+
<title>FastAPI Hello World</title>
|
5 |
+
</head>
|
6 |
+
|
7 |
+
<!-- Stylesheet -->
|
8 |
+
<style>
|
9 |
+
body {
|
10 |
+
font-family: Arial, Helvetica, sans-serif;
|
11 |
+
font-size: 16px;
|
12 |
+
line-height: 1.5;
|
13 |
+
margin: 0;
|
14 |
+
padding: 0;
|
15 |
+
}
|
16 |
+
h1 {
|
17 |
+
font-size: 2em;
|
18 |
+
margin: 0;
|
19 |
+
padding: 0;
|
20 |
+
/* Center */
|
21 |
+
text-align: center;
|
22 |
+
}
|
23 |
+
h3 {
|
24 |
+
margin: 0;
|
25 |
+
padding: 0;
|
26 |
+
/* Center */
|
27 |
+
text-align: center;
|
28 |
+
}
|
29 |
+
|
30 |
+
</style>
|
31 |
+
|
32 |
+
<!-- Body -->
|
33 |
+
<body>
|
34 |
+
<h1>FastAPI Hello World Example</h1>
|
35 |
+
|
36 |
+
<h3>
|
37 |
+
This is a simple example of a FastAPI Hello World application using Docker. See the links below for more information.
|
38 |
+
</h3>
|
39 |
+
<!-- List of different relevant links and descriptions about them -->
|
40 |
+
|
41 |
+
<div style="margin: 0 auto; width: 50%;">
|
42 |
+
|
43 |
+
<ul>
|
44 |
+
<!-- Link to self /docs -->
|
45 |
+
<li>
|
46 |
+
<a href="/docs">This API's Interactive Swaggar Docs</a> - Try the API out here!
|
47 |
+
</li>
|
48 |
+
</ul>
|
49 |
+
</div>
|
50 |
+
|
51 |
+
</body>
|
52 |
+
</html>
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.74.*
|
2 |
+
requests==2.27.*
|
3 |
+
uvicorn[standard]==0.17.*
|