Skip to content

Commit c273da2

Browse files
author
FangJu
committed
feat: 新增必应api
1 parent 68700d4 commit c273da2

File tree

5 files changed

+9
-58
lines changed

5 files changed

+9
-58
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
requests==2.26.0
12
fastapi==0.88.0
23
pytest==7.1.3
34
pytest-asyncio==0.20.3

src/dtos/ISayHelloDto.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/index.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1+
import requests
12
from fastapi import FastAPI
2-
3-
from src.dtos.ISayHelloDto import ISayHelloDto
3+
from fastapi.responses import RedirectResponse
44

55
app = FastAPI()
66

77

88
@app.get("/")
99
async def root():
10-
return {"message": "Hello World"}
11-
12-
13-
@app.get("/hello/{name}")
14-
async def say_hello(name: str):
15-
return {"message": f"Hello {name}"}
10+
return "Hello World!"
1611

1712

18-
@app.post("/hello")
19-
async def hello_message(dto: ISayHelloDto):
20-
return {"message": f"Hello {dto.message}"}
13+
@app.get("/bing/daily")
14+
async def bing():
15+
response = requests.get("https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1")
16+
image_url = "https://www.bing.com" + response.json()["images"][0]["url"]
17+
return RedirectResponse(url=image_url)

test_index.http

Lines changed: 0 additions & 20 deletions
This file was deleted.

test_index.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)