Get JSON format from adwords api report - python

So I'm building an application which has a frontend in React and a backend
in python (pyramid framework).
I recently integrated the google adwords api to query custom reports (doing this in python).
I'm able to get a report from the api by making a query.
However, the response comes either in xml or csv format. The api doesn't support json response at the moment.
My question is: how can I get the data to json format and send it back to my frontend so I can display it in my webapp?

Related

sending data from python to flutter

I am working on developing a mobile application using flutter and I use the Python language as part of the project. I want to know how to send data between flutter and Python, especially sending data from Python to flutter.
For example if i have Python code like this :
**thisdict** = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
i want to send the value of the dictionary thisdict to flutter How to do that ?
I'm assuming the values stored in the dictionary are read from a database, which means you will hav to implement a RESTful-API on Python using Django's REST Framework or Flask's REST Framework.
Django Rest Framework
Flask-RESTful
This API will read values from the database upon a request and send the data back as a JSON object to the user/API Caller with the data required in the dictionary.
To send HTTP Post or GET Requests you will have to use Flutter-BLoC to send POST as well as GET Requests to an API and then capture the Response.
Flutter BLoC
Here's the documentation on FLutter BLoC.

Upload camera video feed to flask rest api

I am trying to deploy a realtime image recognition system in python flask api then call it in a winform desktop application, what's the best way to send the video feed throug a json format.
You can send via base64 format inside json. But best way is designing flask api to expect multipart form data.Even json data + multipart is possible.

WSO2 api manager not sending uploaded multiple files to backend server

I have built a python webservices application using flask.
After creation of swagger document, I published the api in WSO2 API manager.
The publish of API and subscription to the API are successful.
I am able to get authentication token as well.
What I am doing
To consume the API, in Postman/Angular application I am uploading 2 excel file
Files are then sent to WSO2 server url which then sends it to python server
When python server receives the file, it parses it.
Does some calculations and returns the response data object.
Now the problem is at step 3. The files received at Python end are not in the excel format. The data of both the file are combined into one FileStorage object.
Please see the snapshot below
Instead of two One FileStorage object received in request.files
I am trying this all in postman as well as with an angular application and both doesn't work.
I even tried it via swagger at published app's page in WSO2 API manager but that also doesn't works.
Sending Files Via WSO2 Swagger
What only works
When I try the Swagger of published app, Or when I consume the services via postman making a request directly to python's server.
I am getting both the files in proper required format.
File received properly when tried with python app's swagger page
Can you please help me to understand as to what I might be doing wrong.
I am using content type as below
'content-type: multipart/form-data;
After some digging up I found my resolution at Multipart form data file upload using WSO2 API manager?
I added the
<messageBuilder contentType="multipart/form-data"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
<messageFormatter contentType="multipart/form-data"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
inside the JSON Message Builders and JSON Message Formatters section in axis2.xml file at
<API-M_HOME>repository\conf\axis2\axis2.xml

Daily Update from DialogFlow fulfillment python in google assistant

I'm developing an application with Dialogflow and Actions on Google which requires to send daily birthday notification in Google Assistant.
I'm following this documentation to send daily updates. But I'm having trouble because of the language barrier.
I'm developing backed in Python and using fulfillment to serve the request, but that documentation is in Node.js. So I need help to send daily updates.
I've done up to Console setup. Please guide me for further process.(Which JSON req. should I sent?)
If you look down that documentation page a bit here and click the JSON tab, you'll see the specific format you need to configure the subscription to your birthday updates.
Since you're not using a client library, you'll need to write the Python code yourself to respond with the appropriate JSON.

How to write a python program to accept http post requests in JSON format and respond back in JSON format?

Mongodb and all related technologies but (in the last 2 weeks) I have learnt python, mongo db and have written code in python to read csv files, do data wrangling and write the date into mongodb. This part is done.
Now my app sends http requests in JSON format to get the data but I am not sure how to write a python code which listens to this http request, collect the query, fill up with answers and send back the data (answers) in json format. Should I use any frameworks like django or just a simple python program can do this?
Listening for an HTTP request should be done by your web server. I definitely would not recommend writing that part yourself.
If your application serves only a single request URL, with no user authentication, then it might be simple enough to write your own program from scratch.
But if it's more complex than that, i.e. if you want to serve multiple pages or you want your users to log in, I would recommend using a framework such as Django.

Categories