Merge branch 'develop' into 'develop'

Fix Ruby and Python REST API examples

See merge request framasoft/peertube/PeerTube!21
pull/2258/head
Chocobozzz 2019-11-12 14:59:19 +01:00
commit fe02503052
1 changed files with 10 additions and 20 deletions

View File

@ -160,35 +160,25 @@ paths:
http -b GET https://peertube2.cpy.re/api/v1/accounts/{name}/videos
- lang: Ruby
source: |
require 'uri'
require 'net/http'
require 'json'
url = URI("https://peertube2.cpy.re/api/v1/accounts/{name}/videos")
uri = URI.parse("https://peertube2.cpy.re/api/v1/accounts/{name}/videos")
http = Net::HTTP.new(url.host, url.port)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
response = http.request(request)
puts response.read_body
response = http.get(uri.request_uri)
puts JSON.parse(response.read_body)
- lang: Python
source: |
import http.client
import requests
conn = http.client.HTTPSConnection("https://peertube2.cpy.re/api/v1")
r = requests.get("https://peertube2.cpy.re/api/v1//accounts/{name}/videos")
json = r.json()
headers = {
'content-type': "application/json"
}
conn.request("POST", "/accounts/{name}/videos", None, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
print(json)
/accounts:
get:
tags: