Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

flask restful arguments in url

from flask import Flask, request
from flask_restful import Api, Resource

app = Flask(__name__)
api = Api(app)

# Flask mishandles boolean as string
TRUTHY = ['true', 'True', 'yes']

class Item(Resource):
   def get():
      # Get `class` list from request args
      classes = request.args.getlist('class') 

      # Get `analysis` boolean from request args
      analysis = True if request.args.get('analysis') in TRUTHY else False

api.add_resource(Item, '/item')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #flask #restful #arguments #url
ADD COMMENT
Topic
Name
6+2 =