Spaces:
Running
Running
taslim19
commited on
Commit
·
6175f34
1
Parent(s):
55c6269
fix: Add paste function to resolve ImportError
Browse files- DragMusic/utils/pastebin.py +9 -18
DragMusic/utils/pastebin.py
CHANGED
@@ -1,21 +1,12 @@
|
|
1 |
import aiohttp
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
async def post(url: str, *args, **kwargs):
|
7 |
async with aiohttp.ClientSession() as session:
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
async def DragBin(text):
|
17 |
-
resp = await post(f"{BASE}api/v2/paste", data=text)
|
18 |
-
if not resp["success"]:
|
19 |
-
return
|
20 |
-
link = BASE + resp["message"]
|
21 |
-
return link
|
|
|
1 |
import aiohttp
|
2 |
|
3 |
+
async def paste(text: str) -> str:
|
4 |
+
"""Pastes the given text to a pastebin service and returns the link."""
|
|
|
|
|
5 |
async with aiohttp.ClientSession() as session:
|
6 |
+
# Using a simple, no-login-required pastebin service
|
7 |
+
response = await session.post("https://hastebin.com/documents", data=text.encode("utf-8"))
|
8 |
+
if response.status == 200:
|
9 |
+
result = await response.json()
|
10 |
+
return f"https://hastebin.com/{result['key']}"
|
11 |
+
else:
|
12 |
+
return "Failed to paste the content."
|
|
|
|
|
|
|
|
|
|
|
|
|
|