update
swadhinbiswas committed 2 years ago
8cf3335
1 parent e61a084
commit 8cf3335
5 files changed
+38 -26
Showing 5 changed files+38-26
▼.gitignore
+2-1
| @@ -158,4 +158,5 @@ cython_debug/ | ||
158 | 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear |
159 | 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. |
160 | 160 | #.idea/ |
161 | -.vscode/ | |
161 | +.vscode/ | |
162 | +.env/ | |
162 | 163 | |
▼app/__init__.py
+0-0
0 | 0 |
▼app/doodfunction/upload.py
+28-10
| @@ -1,23 +1,41 @@ | ||
1 | -from settings import config as config | |
1 | +from app.setting.config import DOODAPIKEY | |
2 | 2 | # ,STREAMTAPEAPIKEY,STREAMTAPEUSERAGENT |
3 | 3 | import requests |
4 | 4 | from fastapi import APIRouter, File, UploadFile, Form,FastAPI |
5 | 5 | from fastapi.responses import JSONResponse |
6 | 6 | from fastapi.encoders import jsonable_encoder |
7 | 7 | |
8 | -app=FastAPI() | |
9 | 8 | router = APIRouter() |
10 | 9 | |
11 | -@app.get("/userinfo") | |
10 | +@router.get("/userinfo") | |
12 | 11 | async def userinfo(): |
13 | - url=f"https://doodapi.com/api/account/info?key=383661fid15w8jz8w50qza" | |
12 | + url=f"https://doodapi.com/api/account/info?key={DOODAPIKEY}" | |
14 | 13 | response = requests.get(url) |
15 | 14 | return response.json() |
16 | - | |
17 | - | |
18 | - | |
19 | 15 | |
16 | +@router.get("/accountinfo") | |
17 | +async def accountinfo(): | |
18 | + url=f"https://doodapi.com/api/account/stats?key={DOODAPIKEY}" | |
19 | + response = requests.get(url) | |
20 | + return response.json() | |
21 | + | |
22 | + | |
23 | +@router.get("/dmcainfo") | |
24 | +async def dmcainfo(): | |
25 | + url=f"https://doodapi.com/api/dmca/list?key={DOODAPIKEY}" | |
26 | + response = requests.get(url) | |
27 | + return response.json() | |
28 | + | |
29 | +@router.post('/remoteupload') | |
30 | +async def remoteupload(url: str = Form(...), folder_id: str = Form(...)): | |
31 | + url=f"https://doodapi.com/api/remote/upload?key={DOODAPIKEY}&url={url}&folder_id={folder_id}" | |
32 | + response = requests.post(url) | |
33 | + return response.json() | |
34 | + | |
35 | +@router.post('/upload') | |
36 | +async def upload(file: UploadFile = File(...), folder_id: str = Form(...)): | |
37 | + url=f"https://doodapi.com/api/upload?key={DOODAPIKEY}&folder_id={folder_id}" | |
38 | + files = {'file': file.file} | |
39 | + response = requests.post(url, files=files) | |
40 | + return response.json() | |
20 | 41 | |
21 | -if __name__ == "__main__": | |
22 | - import uvicorn | |
23 | - uvicorn.run(app, host="localhost", port=8000) | |
24 | 42 | |
▼app/setting/config.py
+0-4
| @@ -1,5 +1 @@ | ||
1 | 1 | DOODAPIKEY="383661fid15w8jz8w50qza" |
2 | - | |
3 | -from app.schemas.test import printx | |
4 | - | |
5 | -printx() | |
6 | 2 | |
▼app/main.py → main.py
+8-11
| @@ -1,21 +1,18 @@ | ||
1 | -from app import setting | |
1 | + | |
2 | +from app.setting.config import DOODAPIKEY | |
2 | 3 | # ,STREAMTAPEAPIKEY,STREAMTAPEUSERAGENT |
3 | 4 | import requests |
4 | 5 | from fastapi import APIRouter, File, UploadFile, Form,FastAPI |
5 | 6 | from fastapi.responses import JSONResponse |
6 | 7 | from fastapi.encoders import jsonable_encoder |
7 | - | |
8 | +from app.doodfunction.upload import router as doodrouter | |
8 | 9 | app=FastAPI() |
9 | -router = APIRouter() | |
10 | 10 | |
11 | -@app.get("userinfo") | |
12 | -async def userinfo(): | |
13 | - url=f"https://doodapi.com/api/account/info?key={DOODAPIKEY}" | |
14 | - response = requests.get(url) | |
15 | - return response.json() | |
16 | - | |
17 | - | |
18 | - | |
11 | +app.include_router(doodrouter) | |
12 | + | |
13 | +@app.get("/") | |
14 | +async def root(): | |
15 | + return {"message": "Hello World"} | |
19 | 16 | |
20 | 17 | |
21 | 18 | if __name__ == "__main__": |
22 | 19 | |