flask-restful

flask-restful HTTP 500 when uploading file from Android

倾然丶 夕夏残阳落幕 提交于 2020-03-21 06:32:25
问题 I've built a small machine learning project that classifies music based on genre for my project, and I'm serving the feature extraction function through a REST API - flask-restful hosted on Heroku. The function takes in an audio file and returns extracted features such as MFCC. I've tested the local server and the one on Heroku using cURL(POST) and it works just fine, but when I make the same POST request from and Android device it returns a HTTP 500. Now, I've tried two different libraries

RESTful-Flask parsing JSON Arrays with parse_args()

旧街凉风 提交于 2020-03-02 07:44:10
问题 This's my code: parser = reqparse.RequestParser(bundle_errors=True) parser.add_argument('list', type=list, location="json") class Example(Resource): def post(self): #json_data = request.get_json(force=True) json_data = parser.parse_args() return json_data If I post a JSON object like this: { "list" : ["ele1", "ele2", "ele3"] } parser.parse_args() parses it to this python list: 'list': ['e','l','e','1'] request.get_json() works, but I would really like to have the validation of the reqparser..

Extremely long wait time when loading REST resource from angularjs

不问归期 提交于 2020-01-28 18:12:04
问题 I'm building a front-end in angular that is accessing a flask/python RESTful API. I'm using AngularJS v1.2.16. For some reason, it takes an insane amount of time before the REST resource is loaded, with most of the time just waiting. It's my understanding that 'waiting' is measuring the time to first byte - all my services run locally (the frontend, API and database). Given that the services all run locally, I am at a loss how to debug this. Does anybody have any tips on where to look? I

Python can't import module from package

泄露秘密 提交于 2020-01-25 10:20:10
问题 I have a flask restful project with the following layout (file names changed for convenience) myproject/ __init__.py app.py common/ __init__.py util.py foo/ __init__.py main.py utilities.py foo/ is just a folder containing code for one of the API endpoints, I'm planning to add others in the future, for this reason I have common/util.py file which contains reusable functions that I will use with other API endpoints. foo/main.py from flask_restful import Resource, request from utilities import

What is the datetime format for flask-restful parser?

霸气de小男生 提交于 2020-01-21 04:09:10
问题 Let's say that I have following parser inside my get method: from flask.ext.restful import reqparse parser = reqparse.RequestParser() parser.add_argument('when', type=datetime, help='Input wasn\'t valid!') And then I want to test the said get method with curl... curl --data "when=[WHAT SHOULD I WRITE HERE?]" localhost:5000/myGet So the question is, how I should call the get method? I've tried numerous different formats, tried to read rfc228 standard, etc. but I can't figure out the right

How to add fields url for nested output fields in flask restful

笑着哭i 提交于 2020-01-20 09:05:48
问题 I am having difficulty over generating api endpoint urls in nested output fields using [Flask-RESTful][1]. I found that fields.Url('my_endpoint', absolute=True) only generates url inside top url fields not the nested one. It throws werkzeug.routing.BuildError - [Error log gist][1]https://gist.github.com/anonymous/6251c67089871d0e4516 For example here is my url fields role_fields = { 'name': fields.String(attribute='title'), 'id': fields.Integer(attribute='id'), 'uri': fields.Url('user

How to add fields url for nested output fields in flask restful

喜欢而已 提交于 2020-01-20 09:05:27
问题 I am having difficulty over generating api endpoint urls in nested output fields using [Flask-RESTful][1]. I found that fields.Url('my_endpoint', absolute=True) only generates url inside top url fields not the nested one. It throws werkzeug.routing.BuildError - [Error log gist][1]https://gist.github.com/anonymous/6251c67089871d0e4516 For example here is my url fields role_fields = { 'name': fields.String(attribute='title'), 'id': fields.Integer(attribute='id'), 'uri': fields.Url('user

How to add fields url for nested output fields in flask restful

风格不统一 提交于 2020-01-20 09:04:37
问题 I am having difficulty over generating api endpoint urls in nested output fields using [Flask-RESTful][1]. I found that fields.Url('my_endpoint', absolute=True) only generates url inside top url fields not the nested one. It throws werkzeug.routing.BuildError - [Error log gist][1]https://gist.github.com/anonymous/6251c67089871d0e4516 For example here is my url fields role_fields = { 'name': fields.String(attribute='title'), 'id': fields.Integer(attribute='id'), 'uri': fields.Url('user

How to add fields url for nested output fields in flask restful

安稳与你 提交于 2020-01-20 09:04:09
问题 I am having difficulty over generating api endpoint urls in nested output fields using [Flask-RESTful][1]. I found that fields.Url('my_endpoint', absolute=True) only generates url inside top url fields not the nested one. It throws werkzeug.routing.BuildError - [Error log gist][1]https://gist.github.com/anonymous/6251c67089871d0e4516 For example here is my url fields role_fields = { 'name': fields.String(attribute='title'), 'id': fields.Integer(attribute='id'), 'uri': fields.Url('user

how to have a single search API using path parameters (No form used)

妖精的绣舞 提交于 2020-01-07 08:04:11
问题 I have been using this view for searching a word as: db refers mongo connection (just for ref) @app.route('/') def index(): return render_template('index.html') @app.route('/words-<word>', methods=['GET', 'POST']) def wordsearch(word): collection_name=word[0].lower()+'_collection' words=db[collection_name] data=words.find({'word':word}) return render_template('wordsearch.html',data=data) In index.html template I have been doing this to match this above url as: <script type="text/javascript">