flask-restplus

How to pass URLs as parameters in a GET request within python flask (restplus)?

☆樱花仙子☆ 提交于 2020-06-27 18:48:10
问题 I am creating a REST API using python flask. The API is ready and works on port number 8000 of my localhost. Now I intend to give this REST API a user friendly interface for which I decided to go with python - restplus. I thought of calling this service (running on 8000) internally from swagger application running on 5000 I was able to create the basic structure of the API (Swagger). The code for which looks like this: import flask from flask import Flask, request from flask_restplus import

How to pass URLs as parameters in a GET request within python flask (restplus)?

回眸只為那壹抹淺笑 提交于 2020-06-27 18:48:01
问题 I am creating a REST API using python flask. The API is ready and works on port number 8000 of my localhost. Now I intend to give this REST API a user friendly interface for which I decided to go with python - restplus. I thought of calling this service (running on 8000) internally from swagger application running on 5000 I was able to create the basic structure of the API (Swagger). The code for which looks like this: import flask from flask import Flask, request from flask_restplus import

How to document the post body using flask-ReSTplus?

孤人 提交于 2020-06-24 11:53:05
问题 How to document the input body that is expected to be posted in the value field to appear so that the user knows what to post? the following data is used currently: { "customer_id": "", "service_id": "", "customer_name": "", "site_name": "", "service_type": "" } can we populate the value by default with the above json? Code: post_parser = reqparse.RequestParser() post_parser.add_argument('database', type=list, help='user data', location='json') @ns_database.route('/insert_user') class

swagger documenting not loading after deploying the flask app to nginx web server

≡放荡痞女 提交于 2020-01-15 10:27:13
问题 I wrote REST API gateway using flask-restplus plugin, I tested it locally it work using flask run but when I try to run the website on server it works opens in the browser but swagger documentation doesnt shows up in browser console I can see the below error: Here is my site nginx configuration: sites-available $ vi clinic_backend server { listen 80 default_server; listen [::]:80; root /var/www/html; server_name example.com; location /static { alias /var/www/html/static/; } location / { try

flask_restplus' marshal_with returns response with null values

最后都变了- 提交于 2020-01-03 05:17:07
问题 I am using flask_restplus to create a documented API. The marshal decorator controls what data actually gets rendered in your response, but I am having trouble rendering the data. I have the following code: kpis_model = api.model('kpis', { 'cpl_actual': fields.Integer(description='costo por lead total del mes actual'), 'cpl_anterior': fields.Integer(description='costo por lead total del mes anterior'), 'cpl_diferencia': fields.Integer(description='diferencia de cpl_actual y cpl_anterior') })

Flask route at / returns 404 when used with Flask-Restplus

徘徊边缘 提交于 2019-12-24 06:34:05
问题 I have a Flask app which has a Flask-RestPlus API as well as a "/" route. When I try to access "/" however, I get a 404. If I remove the Flask-RestPlus extension, the route works. How do I make both parts work together? from flask import Flask from flask_restplus import Api app = Flask(__name__) api = Api(app, doc="/doc/") # Removing this makes / work @app.route("/") def index(): return "foobar" 回答1: flask-restplus defines a different way of assigning routes according to their docs: @api

“No spec provided” error when trying to deliver swagger.json over HTTPS

人盡茶涼 提交于 2019-12-23 07:56:02
问题 If I try to deliver the Swagger UI using Flask RestPlus over HTTPS, I see only the "No spec provided" error message at the root URL, and the full Swagger UI never loads. However, if I visit the API endpoints they return responses as expected. Looking at the source HTML for the error page, I noticed that swagger.json was being fetched from http://myhost/ rather than https://myhost/ I've discovered exactly the same issue on the restplus Github issues I've fixed my issue temporarily with the

How to deploy a flask-restplus app with nginx + uwgsi

风流意气都作罢 提交于 2019-12-12 22:26:29
问题 I'm having a hard time deploying a Flask app with Flask-Restplus. Everything works great when working locally (wezkrug) in http://localhost:5000/api But when I deploy in a machine my app using nginx + uwgsi, I keep on getting 404 responses from server when accesing http://example.com/api... Looks like Flask-Restplus is using swaggerui for Swagger...do I have to add something in nginx.conf to serve this? Forgive my ignorance but I have no previous experience with nginx This is how I declared

Move Flask-Restplus Swagger API Docs

霸气de小男生 提交于 2019-12-12 09:55:41
问题 I'm trying to use flask-restplus to build a restful API in python. I'd like to have the swagger docs located in a different place than the normal "/". I'm following the documentation here and have followed the instructions. I'm using python2.7.3 and have the following code ~/dev/test/app.py : from flask import Flask from flask.ext.restplus import Api, apidoc app = Flask(__name__) api = Api(app, ui=False) @api.route('/doc/', endpoint='doc') def swagger_ui(): return apidoc.ui_for(api) app

Flask-Restplus / route

一曲冷凌霜 提交于 2019-12-10 19:58:18
问题 I'm trying to use Flask-Restplus to make an api and document it with swagger. This is what I have so far and it works fine except I do not know how to add a root route. from flask import Flask, Blueprint from flask_restplus import Api, Resource, apidoc app = Flask('__name__') blueprint = Blueprint('v1', __name__, url_prefix='/rest/v1') api = Api(blueprint, ui=False, version='1.0') @blueprint.route('/apidoc/', endpoint='apidoc') def swagger_ui(): return apidoc.ui_for(api) @blueprint.route('/',