Compare commits
No commits in common. "fc01f4aa8ab2db92a247641cec4fb45bd0648656" and "394babfff801dccb361528f254fff8fd6260ad32" have entirely different histories.
fc01f4aa8a
...
394babfff8
3 changed files with 12 additions and 15 deletions
18
app.py
18
app.py
|
@ -166,11 +166,11 @@ async def cors_handler(req: Request, call_next: Callable[[Request], Awaitable[Re
|
||||||
@app.get("/api/litey/get")
|
@app.get("/api/litey/get")
|
||||||
async def api_get(id: str = None):
|
async def api_get(id: str = None):
|
||||||
res = JSONResponse(get_litey_notes(id))
|
res = JSONResponse(get_litey_notes(id))
|
||||||
res.headers["Cache-Control"] = f"public, max-age=15, s-maxage=15"
|
res.headers["Cache-Control"] = f"public, max-age=0, s-maxage=0"
|
||||||
res.headers["CDN-Cache-Control"] = f"max-age=15"
|
res.headers["CDN-Cache-Control"] = f"max-age=0"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.post("/api/litey/post", dependencies=[Depends(RateLimiter(times=4, seconds=3600))])
|
@app.post("/api/litey/post")
|
||||||
async def api_post(item: LiteYItem, req: Request):
|
async def api_post(item: LiteYItem, req: Request):
|
||||||
ctx["mongo_client"].litey.notes.insert_one({
|
ctx["mongo_client"].litey.notes.insert_one({
|
||||||
"id": str(uuid4()),
|
"id": str(uuid4()),
|
||||||
|
@ -206,11 +206,11 @@ async def api_image_proxy(url: str):
|
||||||
@app.get("/api/ng/get")
|
@app.get("/api/ng/get")
|
||||||
async def api_ng_get():
|
async def api_ng_get():
|
||||||
res = PlainTextResponse("\n".join(get_ng_words()))
|
res = PlainTextResponse("\n".join(get_ng_words()))
|
||||||
res.headers["Cache-Control"] = f"public, max-age=15, s-maxage=15"
|
res.headers["Cache-Control"] = f"public, max-age=0, s-maxage=0"
|
||||||
res.headers["CDN-Cache-Control"] = f"max-age=15"
|
res.headers["CDN-Cache-Control"] = f"max-age=0"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.post("/api/ng/post", dependencies=[Depends(RateLimiter(times=4, seconds=3600))])
|
@app.post("/api/ng/post")
|
||||||
async def api_ng_post(item: NGItem):
|
async def api_ng_post(item: NGItem):
|
||||||
ctx["mongo_client"].litey.ngs.insert_one({
|
ctx["mongo_client"].litey.ngs.insert_one({
|
||||||
"word": item.word
|
"word": item.word
|
||||||
|
@ -218,7 +218,7 @@ async def api_ng_post(item: NGItem):
|
||||||
|
|
||||||
return PlainTextResponse("OK")
|
return PlainTextResponse("OK")
|
||||||
|
|
||||||
@app.post("/api/ng/delete", dependencies=[Depends(RateLimiter(times=1, seconds=86400))])
|
@app.post("/api/ng/delete")
|
||||||
async def api_ng_delete(item: NGItem):
|
async def api_ng_delete(item: NGItem):
|
||||||
ctx["mongo_client"].litey.ngs.delete_one({
|
ctx["mongo_client"].litey.ngs.delete_one({
|
||||||
"word": item.word
|
"word": item.word
|
||||||
|
@ -232,8 +232,8 @@ async def home(req: Request):
|
||||||
"notes": get_litey_notes(),
|
"notes": get_litey_notes(),
|
||||||
"ng_words": get_ng_words()
|
"ng_words": get_ng_words()
|
||||||
})
|
})
|
||||||
res.headers["Cache-Control"] = f"public, max-age=15, s-maxage=15"
|
res.headers["Cache-Control"] = f"public, max-age=0, s-maxage=0"
|
||||||
res.headers["CDN-Cache-Control"] = f"max-age=15"
|
res.headers["CDN-Cache-Control"] = f"max-age=0"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.get("/{ref:path}")
|
@app.get("/{ref:path}")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
fastapi[standard]==0.115.8
|
fastapi[standard]==0.115.7
|
||||||
pymongo==4.11
|
pymongo==4.10.1
|
||||||
Jinja2==3.1.5
|
Jinja2==3.1.5
|
||||||
fastapi-limiter==0.1.6
|
fastapi-limiter==0.1.6
|
||||||
|
|
|
@ -15,10 +15,7 @@ function notePost() {
|
||||||
msg.value = "";
|
msg.value = "";
|
||||||
alert("投稿に成功しました!");
|
alert("投稿に成功しました!");
|
||||||
} else {
|
} else {
|
||||||
(async () => {
|
alert("投稿に失敗しました。");
|
||||||
const text = await res.text();
|
|
||||||
alert(`投稿に失敗しました。\n${text}`);
|
|
||||||
})();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue