diff options
author | Chocobozzz <chocobozzz@framasoft.org> | 2019-11-12 14:59:19 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@framasoft.org> | 2019-11-12 14:59:19 +0100 |
commit | fe02503052013ca1675aad4ee1eb4a35c2f8359f (patch) | |
tree | 3aa7d191b8f92ff93281b9994925c19a686e74ff /support/doc | |
parent | e8e09e27ff49e694638b7f24dbb97e8de25ac416 (diff) | |
parent | f6d51cfe2aa4c1a1f48dab665cc3bebee178e383 (diff) | |
download | PeerTube-fe02503052013ca1675aad4ee1eb4a35c2f8359f.tar.gz PeerTube-fe02503052013ca1675aad4ee1eb4a35c2f8359f.tar.zst PeerTube-fe02503052013ca1675aad4ee1eb4a35c2f8359f.zip |
Merge branch 'develop' into 'develop'
Fix Ruby and Python REST API examples
See merge request framasoft/peertube/PeerTube!21
Diffstat (limited to 'support/doc')
-rw-r--r-- | support/doc/api/openapi.yaml | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml index a13627a78..032d798fc 100644 --- a/support/doc/api/openapi.yaml +++ b/support/doc/api/openapi.yaml | |||
@@ -160,35 +160,25 @@ paths: | |||
160 | http -b GET https://peertube2.cpy.re/api/v1/accounts/{name}/videos | 160 | http -b GET https://peertube2.cpy.re/api/v1/accounts/{name}/videos |
161 | - lang: Ruby | 161 | - lang: Ruby |
162 | source: | | 162 | source: | |
163 | require 'uri' | ||
164 | require 'net/http' | 163 | require 'net/http' |
164 | require 'json' | ||
165 | 165 | ||
166 | url = URI("https://peertube2.cpy.re/api/v1/accounts/{name}/videos") | 166 | uri = URI.parse("https://peertube2.cpy.re/api/v1/accounts/{name}/videos") |
167 | 167 | ||
168 | http = Net::HTTP.new(url.host, url.port) | 168 | http = Net::HTTP.new(uri.host, uri.port) |
169 | http.use_ssl = true | 169 | http.use_ssl = true |
170 | http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
171 | 170 | ||
172 | request = Net::HTTP::Post.new(url) | 171 | response = http.get(uri.request_uri) |
173 | request["content-type"] = 'application/json' | 172 | |
174 | response = http.request(request) | 173 | puts JSON.parse(response.read_body) |
175 | puts response.read_body | ||
176 | - lang: Python | 174 | - lang: Python |
177 | source: | | 175 | source: | |
178 | import http.client | 176 | import requests |
179 | |||
180 | conn = http.client.HTTPSConnection("https://peertube2.cpy.re/api/v1") | ||
181 | |||
182 | headers = { | ||
183 | 'content-type': "application/json" | ||
184 | } | ||
185 | |||
186 | conn.request("POST", "/accounts/{name}/videos", None, headers) | ||
187 | 177 | ||
188 | res = conn.getresponse() | 178 | r = requests.get("https://peertube2.cpy.re/api/v1//accounts/{name}/videos") |
189 | data = res.read() | 179 | json = r.json() |
190 | 180 | ||
191 | print(data.decode("utf-8")) | 181 | print(json) |
192 | /accounts: | 182 | /accounts: |
193 | get: | 183 | get: |
194 | tags: | 184 | tags: |