This commit is contained in:
sunbeam 2024-12-30 17:03:58 +08:00
commit 9e2e759a7e
3 changed files with 24 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/

11
main.py Normal file
View File

@ -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)

12
web/index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FastAPI Example</title>
</head>
<body>
<h1>Hello, FastAPI!</h1>
<p>This is an example of loading an HTML file using FastAPI.</p>
</body>
</html>