From 9e2e759a7e39ec4bcf0af3c9dcda81538a7d8451 Mon Sep 17 00:00:00 2001 From: sunbeam Date: Mon, 30 Dec 2024 17:03:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5OK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + main.py | 11 +++++++++++ web/index.html | 12 ++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 .gitignore create mode 100644 main.py create mode 100644 web/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c18dd8d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/main.py b/main.py new file mode 100644 index 0000000..5e929d7 --- /dev/null +++ b/main.py @@ -0,0 +1,11 @@ +from fastapi import FastAPI +from fastapi.staticfiles import StaticFiles + +app = FastAPI() + + +app.mount("/", StaticFiles(directory="./web", html=True)) + +if __name__ == "__main__": + import uvicorn + uvicorn.run(app, host="0.0.0.0", port=8000) \ No newline at end of file diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..697fc76 --- /dev/null +++ b/web/index.html @@ -0,0 +1,12 @@ + + + + + + FastAPI Example + + +

Hello, FastAPI!

+

This is an example of loading an HTML file using FastAPI.

+ + \ No newline at end of file