flask-restful

Python flask not working with url containing "?"

Python flask not working with url containing "?" Question: I am new to flask and I was trying to make GET request for url containing "?" symbol but it look like my program is just skipping work with it. I am working with flask-sql alchemy, flask and flask-restful. Some simplified look of my program looks …

Total answers: 2

Issue in uploading image for prediction using a MultiPart POST Request

Issue in uploading image for prediction using a MultiPart POST Request Question: The call is currently happening via a Flutter application which makes a multi-part POST request. Flutter Code var request = http.MultipartRequest( ‘POST’, Uri.parse(‘https://techfarmtest.herokuapp.com/upload’), ); Map<String, String> headers = {"Content-type": "multipart/form-data"}; request.files.add( http.MultipartFile( widget.selectedImage.toString(), widget.selectedImage.readAsBytes().asStream(), widget.selectedImage.lengthSync(), filename: widget.selectedImage.path.split(‘/’).last, ), ); request.headers.addAll(headers); var res = …

Total answers: 1

Cant receive Post Data to gcloud flask api from fetch function in react app

Cant receive Post Data to gcloud flask api from fetch function in react app Question: I have a very simple api that is written in Flask and deployed to cloud cloud run. I am collecting data from the client and passing it to a cloud run flask api, and once flask receives the post request …

Total answers: 1

converting Flask message received in in "text/plain" format to JSON format

converting Flask message received in in "text/plain" format to JSON format Question: I have an issue with FLASK that I am hoping to resolve. I am sending this type of input to a Flask server: [ "tradeid": "5L5A0", "message": "", "accountid": 20, "ticker": {{ticker}}, "currentprice": {{close}}, "action": "X_OPEN" ] I have also tried (changing ] …

Total answers: 1

Flask-Restful Error: request Content-Type was not 'application/json'."}

Flask-Restful Error: request Content-Type was not 'application/json'."} Question: I was following this tutorial and it was going pretty well. He then introduced reqparse and I followed along. I tried to test my code and I get this error {‘message’: "Did not attempt to load JSON data because the request Content-Type was not ‘application/json’."} I don’t …

Total answers: 7

How to disable csrf for a view with flask-wft for a restapi?

How to disable csrf for a view with flask-wft for a restapi? Question: I get problem for disable csrf using flask-wtf for a restapi. The problem is similar like here: Flask-Restful POST fails due CSRF protection of Flask-WTF, but I use flask original instead of flask-restful. I use the @csrf.exemptdecorator, and I did exactly like …

Total answers: 3

How to send an image to a flask server using Postman

How to send an image to a flask server using Postman Question: I need to send an image file to a flask server using Postman.I did send it using a web browser and “render template”.But when i tried the same program with postman it showed “method not allowed” . I also tried /upload, but it …

Total answers: 3

flask request args parser error The browser (or proxy) sent a request that this server could not understand

flask request args parser error The browser (or proxy) sent a request that this server could not understand Question: using test_client and sending a request like so: app = Flask(__name__) client = app.test_client() headers = {‘content-type’: ‘application/json’, ‘Authorization’: u’Bearer fake_token_123′} params = {‘dont_care’: True} client.get(ֿֿ’/my_route/123′, query_string=params, headers=headers) my route is class MyController(Resource): def get(self, id): …

Total answers: 2

Python-flask extracting values from a POST request to REST API

Python-flask extracting values from a POST request to REST API Question: I am trying to extract values from a JSON payload by POST request: Question 1: What is a better way to get the data? First Way? @app.route(‘/login’, methods=[‘POST’]) def login(): if request.method == ‘POST’: test = request.data return test or Second Way? @app.route(‘/login’, methods=[‘POST’]) …

Total answers: 2

Use Auth0 decorator with Flask-RESTful resource

Use Auth0 decorator with Flask-RESTful resource Question: I need to use Auth0 for my Flask-RESTful app. Auth0 has an example using the requires_auth decorator on a view function. @app.route(‘/secured/ping’) @cross_origin(headers=[‘Content-Type’, ‘Authorization’]) @requires_auth def securedPing(): return "All good. You only get this message if you’re authenticated" With Flask-RESTful I use add_resource with a Resource class, not …

Total answers: 1