def index(): ''' try: import googleclouddebugger googleclouddebugger.enable() except ImportError: pass ''' ''' headers = { "Authorization": "Bearer your_access_token", "Lw-Client": "your_client_id" } data = readfromurl('https://api.learnworlds.com/courses', headers=headers) ''' #get the data from local sample file data = readfromurl(request.url + 'static/courses.json') resp = Response(response=json2xml.Json2xml(data).to_xml(), status=200, mimetype="application/xml") #resp = 'Hello' return resp
def test_read_from_wrong_url(self): """ Use wrong url and check if there is a sytemExit """ with pytest.raises(SystemExit) as pytest_wrapped_e: data = readfromurl("https://coderwall.com/vinitcool76.jsoni") print("type is ", pytest_wrapped_e.type) assert pytest_wrapped_e.type == SystemExit
from json2xml import json2xml, readfromurl, readfromstring, readfromjson # get the xml from an URL that return json data = readfromurl("https://coderwall.com/vinitcool76.json") print(json2xml.Json2xml(data).to_xml()) print('-----------------------------------------') # get the xml from a json string data = readfromstring( '{"login":"******","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}' ) print(json2xml.Json2xml(data, wrapper="custom", indent=8).to_xml()) print('-----------------------------------------') # get the data from an URL # check for empty data = readfromjson("example.json") print(json2xml.Json2xml(data).to_xml()) print('-----------------------------------------')
def json_2_xml_url(url): data_fromUrl = readfromurl(url) data_fromUrl_xml = json2xml.Json2xml(data_fromUrl).to_xml() print(data_fromUrl_xml)
def test_read_from_url(self): data = readfromurl("https://coderwall.com/vinitcool76.json") assert type(data) is dict