|
12 | 12 | </div>
|
13 | 13 | <br>
|
14 | 14 |
|
15 |
| -A small simple wrapper around the [MystB.in](https://mystb.in/) API. |
| 15 | +A small simple wrapper around the [Mystb.in](https://mystb.in/) API. |
16 | 16 | API docs can be found [here](https://api.mystb.in/docs).
|
17 | 17 | ----------
|
18 | 18 | ### Features
|
@@ -49,29 +49,37 @@ import mystbin
|
49 | 49 |
|
50 | 50 | mystbin_client = mystbin.Client()
|
51 | 51 |
|
52 |
| -paste = await mystbin_client.post("Hello from MystBin!", syntax="python") |
| 52 | +paste = await client.create_paste(filename="Hello.txt", content="Hello there!", syntax="txt") |
53 | 53 | str(paste)
|
54 |
| ->>> 'https://mystb.in/<your generated ID>.python' |
| 54 | +>>> 'https://mystb.in/<your generated ID>' |
55 | 55 |
|
56 |
| -paste.url |
57 |
| ->>> 'https://mystb.in/<your generated ID>.python' |
| 56 | +get_paste = await mystbin_client.get_paste("<your generated ID>") |
| 57 | +get_paste.files[0].content |
| 58 | +>>> "Hello there!" |
58 | 59 |
|
59 |
| -get_paste = await mystbin_client.get("https://mystb.in/<your generated ID>") |
60 |
| -str(get_paste) |
61 |
| ->>> "Hello from MystBin!" |
62 |
| - |
63 |
| -paste.created_at |
| 60 | +get_paste.created_at |
64 | 61 | >>> datetime.datetime(2020, 10, 6, 10, 53, 57, 556741)
|
65 | 62 | ```
|
66 | 63 |
|
| 64 | +Or if you want to create a paste with multiple files... |
67 | 65 | ```py
|
68 | 66 | import mystbin
|
69 | 67 |
|
70 |
| -mystbin_client = mystbin.SyncClient() |
| 68 | +file = mystbin.File(filename="File1.txt", content="Hello there!", syntax="txt") |
| 69 | +file2 = mystbin.File(filename="test.py", content="print('hello!')", syntax="py") |
71 | 70 |
|
72 |
| -paste = mystbin_client.post("Hello from sync Mystb.in!", syntax="text") |
73 |
| -str(paste) |
74 |
| ->>> 'https://mystb.in/<your generated ID>.text' |
| 71 | +paste = await client.create_multifile_paste(files=[file, file2]) |
| 72 | + |
| 73 | +for file in paste.files: |
| 74 | + print(file.content) |
| 75 | + |
| 76 | +>>> "Hello there!" |
| 77 | +>>> "print('hello!')" |
75 | 78 | ```
|
76 | 79 |
|
77 |
| -NOTE: There is a timeout of 15s for each operation. |
| 80 | +If you have any question please feel free to join the Pythonista Discord server: |
| 81 | +<div align="left"> |
| 82 | + <a href="https://discord.gg/RAKc3HF"> |
| 83 | + <img src="https://discordapp.com/api/guilds/490948346773635102/widget.png?style=banner2" alt="Discord Server"/> |
| 84 | + </a> |
| 85 | +</div> |
0 commit comments