mirror of
https://github.com/PaiGramTeam/EASY_PROXY.git
synced 2024-11-27 01:53:23 +00:00
feat: support bbs oss proxy
This commit is contained in:
parent
7f4f6ca9a7
commit
8df84b165f
2
.gitignore
vendored
2
.gitignore
vendored
@ -157,4 +157,4 @@ cython_debug/
|
||||
# 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
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
.idea/
|
||||
|
31
main.py
Normal file
31
main.py
Normal file
@ -0,0 +1,31 @@
|
||||
from fastapi import FastAPI
|
||||
from httpx import AsyncClient
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import Response
|
||||
|
||||
app = FastAPI()
|
||||
client = AsyncClient(
|
||||
timeout=60.0,
|
||||
)
|
||||
|
||||
|
||||
@app.get('/upload/{file_path:path}')
|
||||
async def proxy_cve_search_api(req: Request, file_path: str) -> Response:
|
||||
headers = {}
|
||||
for i in req.headers.items():
|
||||
headers[i[0]] = i[1]
|
||||
headers["host"] = "upload-bbs.miyoushe.com"
|
||||
resp = await client.get(
|
||||
f'https://upload-bbs.miyoushe.com/upload/{file_path}',
|
||||
params=req.query_params,
|
||||
headers=headers,
|
||||
follow_redirects=True,
|
||||
)
|
||||
content = resp.content
|
||||
return Response(content=content, status_code=resp.status_code, headers=dict(resp.headers))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(app, host="0.0.0.0", port=5677)
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
httpx==0.24.1
|
||||
fastapi~=0.95.2
|
||||
starlette~=0.27.0
|
||||
uvicorn~=0.22.0
|
Loading…
Reference in New Issue
Block a user