dog commited on
Commit
950525a
·
1 Parent(s): aa80554

Upload . with huggingface_hub

Browse files
Files changed (5) hide show
  1. Dockerfile +11 -0
  2. __pycache__/app.cpython-38.pyc +0 -0
  3. app.py +20 -0
  4. index.html +52 -0
  5. requirements.txt +3 -0
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"]
__pycache__/app.cpython-38.pyc ADDED
Binary file (792 Bytes). View file
 
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 Swaggar Docs</a> - Swaggar Docs for this API (auto-generated from the OpenAPI standard). These docs are interactive, so you can try out the API directly from the docs.
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.*