flask_easyapi package¶
Submodules¶
flask_easyapi.flask_easyapi module¶
-
class
flask_easyapi.flask_easyapi.
EasyAPI
(name: str, import_name: str, *args, **kwargs)[source]¶ Bases:
flask.blueprints.Blueprint
EasyAPI is an object that makes defining a collection of related rest-api easier.
Represents a collection of related rest-api routes that can later be registered on a real application.
Parameters: - name – The name of the blueprint. Will be prepended to each endpoint name.
- import_name – The name of the blueprint package, usually
__name__
. This helps locate theroot_path
for the blueprint.
Keyword arguments passed to Blueprint
See flask Blueprint api for up-to-date information. The following is an extract of docs under BSD-3-Clause License:
Parameters: - static_folder – A folder with static files that should be served by the blueprint’s static route. The path is relative to the blueprint’s root path. Blueprint static files are disabled by default.
- static_url_path – The url to serve static files from.
Defaults to
static_folder
. If the blueprint does not have aurl_prefix
, the app’s static route will take precedence, and the blueprint’s static files won’t be accessible. - template_folder – A folder with templates that should be added to the app’s template search path. The path is relative to the blueprint’s root path. Blueprint templates are disabled by default. Blueprint templates have a lower precedence than those in the app’s templates folder.
- url_prefix – A path to prepend to all of the blueprint’s URLs, to make them distinct from the rest of the app’s routes.
- subdomain – A subdomain that blueprint routes will match on by default.
- url_defaults – A dict of default values that blueprint routes will receive by default.
- root_path – By default, the blueprint will automatically this
based on
import_name
. In certain situations this automatic detection can fail, so the path can be specified manually instead.
-
route
(rule: str, **options)[source]¶ A decorator that is used to register an api endpoint and its handler. The decorated function will automatically receive the url parameters as kwargs.
Note
As of v0.1.0 unlike Blueprint,
route()
andadd_url_rule()
behaves differently for EasyAPI, this difference is expected to disappear in later releases.Parameters: rule – The URL rule as string. See flask route registrations api Keyword arguments passed to Blueprint
See flask route api for up-to-date information. The following is an extract of docs under BSD-3-Clause License:
Parameters: - endpoint – the endpoint for the registered URL rule. Flask itself assumes the name of the view function as endpoint
- options – the options to be forwarded to the underlying
Rule
object. A change to Werkzeug is handling of method options. methods is a list of methods this rule should be limited to (GET
,POST
etc.). By default a rule just listens forGET
(and implicitlyHEAD
). Starting with Flask 0.6,OPTIONS
is implicitly added and handled by the standard request handling.
Module contents¶
Flask-EasyAPI¶
EasyAPI is a flask extension that aims to make writing rest-api with flask very easy.
COPYRIGHT: Harsh Parekh LICENSE: MIT