Compare commits

..

No commits in common. "ee0762b0b1d7a85e7b5a109805e9d8a59f922170" and "7cb5e177fcde6f080da73590fb3836bf0b64d88e" have entirely different histories.

4 changed files with 1 additions and 58 deletions

1
.gitignore vendored
View File

@ -3,4 +3,3 @@
__pycache__ __pycache__
venv venv
__pycache__/main.cpython-311.pyc __pycache__/main.cpython-311.pyc
pictures/

Binary file not shown.

View File

@ -1,5 +1,6 @@
from fastapi import FastAPI, HTTPException, Request from fastapi import FastAPI, HTTPException, Request
from fastapi.responses import FileResponse from fastapi.responses import FileResponse
import base64
import os import os
app = FastAPI() app = FastAPI()

View File

@ -1,57 +0,0 @@
from fastapi import FastAPI, HTTPException, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
import os
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173"], # 允许的源列表
allow_credentials=True,
allow_methods=["*"], # 允许的方法
allow_headers=["*"], # 允许的头
)
@app.get("/")
async def root():
return "welcome to fastAPI!"
@app.get("/api/get-menu")
async def get_menu():
menu_list = [
{"id": 1, "menu_name": "首页", "url": "/", "src": "/index.svg"},
{"id": 2, "menu_name": "图片", "url": "/photos", "src": "/photo.svg"},
{"id": 3, "menu_name": "视频", "url": "/videos", "src": "/videos.svg"},
{"id": 4, "menu_name": "关于", "url": "/about", "src": "/about.svg"}
]
return {
"code": 0,
"msg": "ok",
"data": menu_list
}
@app.get("/api/get-photo-list")
async def get_photo_list():
photo_list = [
{"id": 1, "photo_name": "1", "photo_size": "1", "url": "/index.svg"},
{"id": 2, "photo_name": "2", "photo_size": "1", "url": "/photo.svg"},
{"id": 3, "photo_name": "3", "photo_size": "1", "url": "/videos.svg"},
{"id": 4, "photo_name": "4", "photo_size": "1", "url": "/about.svg"},
{"id": 5, "photo_name": "5", "photo_size": "1", "url": "/index.svg"},
{"id": 6, "photo_name": "6", "photo_size": "1", "url": "/photo.svg"},
{"id": 7, "photo_name": "7", "photo_size": "1", "url": "/videos.svg"},
{"id": 8, "photo_name": "8", "photo_size": "1", "url": "/about.svg"},
{"id": 9, "photo_name": "9", "photo_size": "1", "url": "/index.svg"},
{"id": 10, "photo_name": "10", "photo_size": "1", "url": "/photo.svg"},
{"id": 11, "photo_name": "11", "photo_size": "1", "url": "/videos.svg"},
{"id": 12, "photo_name": "12", "photo_size": "1", "url": "/about.svg"}
]
return {
"code": 0,
"msg": "ok",
"data": photo_list
}