mirror of
https://github.com/PaiGramTeam/luoxu-api-pub.git
synced 2024-11-23 08:10:57 +00:00
init push
This commit is contained in:
parent
f3c0a621a1
commit
559ea86cb3
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,7 +8,6 @@ __pycache__/
|
|||||||
|
|
||||||
# Distribution / packaging
|
# Distribution / packaging
|
||||||
.Python
|
.Python
|
||||||
build/
|
|
||||||
develop-eggs/
|
develop-eggs/
|
||||||
dist/
|
dist/
|
||||||
downloads/
|
downloads/
|
||||||
@ -157,4 +156,4 @@ cython_debug/
|
|||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
.idea/
|
||||||
|
1
html/build/bundle.css
Normal file
1
html/build/bundle.css
Normal file
@ -0,0 +1 @@
|
|||||||
|
main.svelte-cd7t1.svelte-cd7t1{margin:1em}button.svelte-cd7t1.svelte-cd7t1{white-space:nowrap}#searchbox.svelte-cd7t1.svelte-cd7t1{display:flex;margin-left:1px}#searchbox.svelte-cd7t1>*{margin-left:-1px}#searchbox.svelte-cd7t1 input[type="search"].svelte-cd7t1{flex-grow:1}@media(max-width: 700px){#searchbox.svelte-cd7t1.svelte-cd7t1{flex-direction:column}}.error.svelte-cd7t1.svelte-cd7t1{color:red;text-align:center}.info.svelte-cd7t1.svelte-cd7t1{display:flex;justify-content:center}.info.svelte-cd7t1>.svelte-cd7t1{padding:0.5em 1em;margin:1em 0}.info.svelte-cd7t1>p.svelte-cd7t1{border:1px #bfbfbf solid;border-radius:2em}input,button,select{border-radius:0;border:1px solid var(--color-inactive);height:2.3em}input:focus,button:focus,select:focus{border-color:var(--color-active);outline:1px solid var(--color-active);z-index:10}:root{--color-inactive:#bfbfbf;--color-active:#add8e6}.message.svelte-15hb0c4.svelte-15hb0c4{margin:1em 0;padding:0.5em;max-width:max-content;border:1px #eeeeee solid;box-shadow:0 0 3px gray;border-radius:5px;display:flex}.avatar.svelte-15hb0c4.svelte-15hb0c4{padding-right:0.5em}.content.svelte-15hb0c4.svelte-15hb0c4{overflow:hidden}.name.svelte-15hb0c4.svelte-15hb0c4{white-space:nowrap;color:#1e90ff;overflow:hidden;text-overflow:ellipsis}.text.svelte-15hb0c4.svelte-15hb0c4{white-space:pre-wrap;margin:0.2em 0}.text.svelte-15hb0c4>.keyword{background-color:#ffffab}.time.svelte-15hb0c4.svelte-15hb0c4{font-size:0.75em;float:right;margin-right:2px}.time.svelte-15hb0c4.svelte-15hb0c4,.time.svelte-15hb0c4>a.svelte-15hb0c4{color:gray}div.svelte-179qc5o.svelte-179qc5o{position:relative}ul.svelte-179qc5o.svelte-179qc5o{list-style:none;padding:0;margin:0;position:absolute;left:0;background-color:white;box-shadow:0 0 4px var(--color-inactive);clip-path:polygon(-100% 0, 200% 0, 200% 200%, -100% 200%)}li.svelte-179qc5o.svelte-179qc5o{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;line-height:2em}li.svelte-179qc5o>img.svelte-179qc5o{height:calc(2.3em - 2px);width:calc(2.3em - 2px);vertical-align:middle;padding-right:0.5em;display:inline-block;overflow:hidden}ul.svelte-179qc5o:not(:hover)>li.selected.svelte-179qc5o,li.svelte-179qc5o.svelte-179qc5o:hover{background-color:#d9f5ff}input.svelte-179qc5o.svelte-179qc5o{padding-left:2.5em;width:100%}input.svelte-179qc5o.svelte-179qc5o,ul.svelte-179qc5o.svelte-179qc5o{border-radius:0;border:1px solid var(--color-inactive)}input.svelte-179qc5o.svelte-179qc5o:focus,input.svelte-179qc5o:focus~ul.svelte-179qc5o{border-color:var(--color-active);box-shadow:0 0 4px var(--color-active);outline:1px solid var(--color-active)}input.svelte-179qc5o:focus~ul.svelte-179qc5o{border-top-color:var(--color-inactive)}.selected-avatar.svelte-179qc5o.svelte-179qc5o{position:absolute;pointer-events:none;top:1px;left:1px;height:calc(2.3em - 2px);width:calc(2.3em - 2px)}.hidden.svelte-179qc5o.svelte-179qc5o{display:none}
|
2
html/build/bundle.js
Normal file
2
html/build/bundle.js
Normal file
File diff suppressed because one or more lines are too long
1
html/build/bundle.js.map
Normal file
1
html/build/bundle.js.map
Normal file
File diff suppressed because one or more lines are too long
BIN
html/favicon.png
Normal file
BIN
html/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
65
html/global.css
Normal file
65
html/global.css
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
html, body {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
color: #333;
|
||||||
|
margin: 0;
|
||||||
|
padding: 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
line-height: 1.2;
|
||||||
|
/* Google Chrome defaults to Times New Roman and for sans-serif it prefers Arial... */
|
||||||
|
font-family: 'DejaVu Sans', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: rgb(0,100,200);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:visited {
|
||||||
|
color: rgb(0,80,160);
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
input, button, select, textarea {
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
-webkit-padding: 0.4em 0;
|
||||||
|
padding: 0.4em;
|
||||||
|
margin: 0 0 0.5em 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:disabled {
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
color: #333;
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:not(:disabled):active {
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:focus {
|
||||||
|
border-color: #666;
|
||||||
|
}
|
18
html/index.html
Normal file
18
html/index.html
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||||
|
|
||||||
|
<title>落絮</title>
|
||||||
|
|
||||||
|
<link rel='icon' type='image/png' href='favicon.png'>
|
||||||
|
<link rel='stylesheet' href='global.css'>
|
||||||
|
<link rel='stylesheet' href='build/bundle.css'>
|
||||||
|
|
||||||
|
<script defer src='build/bundle.js'></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
85
main.py
Normal file
85
main.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
from fastapi import FastAPI
|
||||||
|
from httpx import AsyncClient
|
||||||
|
from starlette.middleware.cors import CORSMiddleware
|
||||||
|
from starlette.requests import Request
|
||||||
|
from starlette.responses import StreamingResponse, RedirectResponse
|
||||||
|
from starlette.staticfiles import StaticFiles
|
||||||
|
|
||||||
|
app = FastAPI()
|
||||||
|
local_api = "http://127.0.0.1:9008/luoxu/"
|
||||||
|
allowed_origins = [
|
||||||
|
"search-pub.xtaolabs.com",
|
||||||
|
"127.0.0.1:9009",
|
||||||
|
]
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=allowed_origins,
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
groups_id = [1366383997, 1797471403]
|
||||||
|
groups = {
|
||||||
|
"groups": [
|
||||||
|
{
|
||||||
|
"group_id": "1366383997",
|
||||||
|
"name": "原神 · 提瓦特大陆",
|
||||||
|
"pub_id": "GenshinImpact"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group_id": "1797471403",
|
||||||
|
"name": "崩坏:星穹铁道 · 仙舟:罗浮",
|
||||||
|
"pub_id": "HSRCN_Group"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/luoxu/groups")
|
||||||
|
async def get_groups():
|
||||||
|
return groups
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/luoxu/search")
|
||||||
|
async def get_search(request: Request):
|
||||||
|
try:
|
||||||
|
if int(request.query_params.get("g", 0)) in groups_id:
|
||||||
|
async with AsyncClient(timeout=60) as client:
|
||||||
|
r = await client.get(f"{local_api}search", params=request.query_params)
|
||||||
|
return r.json()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/luoxu/names")
|
||||||
|
async def get_names(request: Request):
|
||||||
|
try:
|
||||||
|
if int(request.query_params.get("g", 0)) in groups_id:
|
||||||
|
async with AsyncClient(timeout=60) as client:
|
||||||
|
r = await client.get(f"{local_api}names", params=request.query_params)
|
||||||
|
return r.json()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/luoxu/avatar/{avatar}")
|
||||||
|
async def read_avatar(avatar: str) -> StreamingResponse:
|
||||||
|
async with AsyncClient(timeout=60) as client:
|
||||||
|
r = await client.get(f"{local_api}avatar/{avatar}")
|
||||||
|
return StreamingResponse(r.aiter_bytes(), media_type="image/png")
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/")
|
||||||
|
async def redirect_to_html():
|
||||||
|
return RedirectResponse(url="/index.html")
|
||||||
|
|
||||||
|
|
||||||
|
app.mount("/", StaticFiles(directory="html"), name="html")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import uvicorn
|
||||||
|
|
||||||
|
uvicorn.run(app, port=9009)
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
fastapi==0.101.0
|
||||||
|
uvicorn==0.23.2
|
||||||
|
httpx==0.24.1
|
||||||
|
starlette
|
Loading…
Reference in New Issue
Block a user