wnm168 commited on
Commit
152d722
·
verified ·
1 Parent(s): 059e444

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +25 -11
main.py CHANGED
@@ -30,6 +30,25 @@ class PostRequest(BaseModel):
30
  extra = Extra.allow
31
 
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  security = HTTPBearer()
34
  # SECRET_TOKEN = "SECRET_TOKEN"
35
  SECRET_TOKEN = os.getenv("SECRET_TOKEN")
@@ -121,22 +140,17 @@ async def home(request: Request):
121
 
122
 
123
  @app.get("/files")
124
- async def get_files(
125
- size: int = 100,
126
- parent_id: Optional[str] = None,
127
- next_page_token: Optional[str] = None,
128
- additional_filters: Optional[Dict[str, Any]] = None,
129
- ):
130
  return await THUNDERX_CLIENT.file_list(
131
- size, parent_id, next_page_token, additional_filters
132
  )
133
 
134
 
135
  @app.get("/offline")
136
- async def offline(
137
- file_url: str, parent_id: Optional[str] = None, name: Optional[str] = None
138
- ):
139
- return await THUNDERX_CLIENT.offline_download(file_url, parent_id, name)
140
 
141
 
142
  @app.get("/userinfo")
 
30
  extra = Extra.allow
31
 
32
 
33
+ class FileRequest(BaseModel):
34
+ size: int = (100,)
35
+ parent_id: Optional[str] = (None,)
36
+ next_page_token: Optional[str] = (None,)
37
+ additional_filters: Optional[Dict[str, Any]] = (None,)
38
+
39
+ class Config:
40
+ extra = Extra.allow
41
+
42
+
43
+ class OfflineRequest(BaseModel):
44
+ file_url: str
45
+ parent_id: Optional[str] = None
46
+ name: Optional[str] = None
47
+
48
+ class Config:
49
+ extra = Extra.allow
50
+
51
+
52
  security = HTTPBearer()
53
  # SECRET_TOKEN = "SECRET_TOKEN"
54
  SECRET_TOKEN = os.getenv("SECRET_TOKEN")
 
140
 
141
 
142
  @app.get("/files")
143
+ async def get_files(item: FileRequest):
 
 
 
 
 
144
  return await THUNDERX_CLIENT.file_list(
145
+ item.size, item.parent_id, item.next_page_token, item.additional_filters
146
  )
147
 
148
 
149
  @app.get("/offline")
150
+ async def offline(item: OfflineRequest):
151
+ return await THUNDERX_CLIENT.offline_download(
152
+ item.file_url, item.parent_id, item.name
153
+ )
154
 
155
 
156
  @app.get("/userinfo")