flask API reference
62 public APIs from flask (pallets/flask) — 11 classes, 17 functions, 34 methods. Signatures extracted by static analysis of the actual source.
Repository: pallets/flask
| Kind | Count |
|---|---|
| Classes | 11 |
| Functions | 17 |
| Methods | 34 |
API list
method
src.flask.blueprints.Blueprint.send_static_file(filename:str) -> ResponseThe view function used to serve files from :attr:`static_folder`.
class
src.flask.cli.CertParamTypeClick option type for the ``--cert`` option.
class
src.flask.cli.NoAppExceptionRaised if an application cannot be found or loaded.
class
src.flask.cli.ScriptInfoHelper object to deal with Flask applications.
method
src.flask.cli.ScriptInfo.load_app() -> FlaskLoads the Flask app (if not yet loaded) and returns it.
func
src.flask.cli.find_app_by_string(module:ModuleType, app_name:str) -> FlaskCheck if the given string is a variable name or a function.
func
src.flask.cli.load_dotenv(path:str | os.PathLike[str] | None=None, load_defaults:bool=True) -> boolLoad "dotenv" files to set environment variables.
func
src.flask.cli.routes_command(sort:str, all_methods:bool) -> NoneShow all registered routes with endpoints and methods.
method
src.flask.config.Config.from_object(obj:object | str) -> NoneUpdates the values from the given object.
method
src.flask.config.Config.from_pyfile(filename:str | os.PathLike[str], silent:bool=False) -> boolUpdates the values in the config from a Python file.
class
src.flask.config.ConfigAttributeMakes an attribute forward to the config
func
src.flask.ctx.after_this_request(f:ft.AfterRequestCallable[t.Any]) -> ft.AfterRequestCallable[t.Any]Decorate a function to run after the current request.
func
src.flask.ctx.copy_current_request_context(f:F) -> FDecorate a function to run inside the current request context.
func
src.flask.ctx.has_app_context() -> boolTest if an app context is active.
class
src.flask.debughelpers.DebugFilesKeyErrorRaised from request.files during debugging.
func
src.flask.helpers.flash(message:str, category:str='message') -> NoneFlashes a message to the next request.
func
src.flask.helpers.get_root_path(import_name:str) -> strFind the root path of a package, or the path that contains a module.
func
src.flask.helpers.get_template_attribute(template_name:str, attribute:str) -> t.AnyLoads a macro (or variable) a template exports.
func
src.flask.helpers.make_response(*args:t.Any) -> ResponseSometimes it is necessary to set additional headers in a view.
func
src.flask.helpers.redirect(location:str, code:int=303, Response:type[BaseResponse] | None=None) -> BaseResponseCreate a redirect response object.
func
src.flask.json.dump(obj:t.Any, fp:t.IO[str], **kwargs:t.Any) -> NoneSerialize data as JSON and write to a file.
func
src.flask.json.dumps(obj:t.Any, **kwargs:t.Any) -> strSerialize data as JSON.
func
src.flask.json.load(fp:t.IO[t.AnyStr], **kwargs:t.Any) -> t.AnyDeserialize data as JSON read from a file.
func
src.flask.json.loads(s:str | bytes, **kwargs:t.Any) -> t.AnyDeserialize data as JSON.
class
src.flask.json.provider.JSONProviderA standard set of JSON operations for an application.
method
src.flask.json.provider.JSONProvider.dump(obj:t.Any, fp:t.IO[str], **kwargs:t.Any) -> NoneSerialize data as JSON and write to a file.
method
src.flask.json.provider.JSONProvider.dumps(obj:t.Any, **kwargs:t.Any) -> strSerialize data as JSON.
method
src.flask.json.provider.JSONProvider.load(fp:t.IO[t.AnyStr], **kwargs:t.Any) -> t.AnyDeserialize data as JSON read from a file.
method
src.flask.json.provider.JSONProvider.loads(s:str | bytes, **kwargs:t.Any) -> t.AnyDeserialize data as JSON.
method
src.flask.json.tag.JSONTag.check(value:t.Any) -> boolCheck if the given value should be tagged by this tag.
method
src.flask.json.tag.JSONTag.to_json(value:t.Any) -> t.AnyConvert the Python object to an object that is a valid JSON type.
method
src.flask.json.tag.JSONTag.to_python(value:t.Any) -> t.AnyConvert the JSON representation back to the correct type.
class
src.flask.json.tag.TagDictTag for 1-item dicts whose only key matches a registered tag.
func
src.flask.logging.create_logger(app:App) -> logging.LoggerGet the Flask app's logger and configure it if needed.
method
src.flask.sansio.app.App.add_template_filter(f:ft.TemplateFilterCallable, name:str | None=None) -> NoneRegister a function to use as a custom Jinja filter.
method
src.flask.sansio.app.App.add_template_global(f:ft.TemplateGlobalCallable, name:str | None=None) -> NoneRegister a function to use as a custom Jinja global.
method
src.flask.sansio.app.App.add_template_test(f:ft.TemplateTestCallable, name:str | None=None) -> NoneRegister a function to use as a custom Jinja test.
method
src.flask.sansio.app.App.create_global_jinja_loader() -> DispatchingJinjaLoaderCreates the loader for the Jinja environment.
method
src.flask.sansio.app.App.debug() -> boolWhether debug mode is enabled.
method
src.flask.sansio.app.App.jinja_env() -> EnvironmentThe Jinja environment used to load templates.
method
src.flask.sansio.app.App.make_aborter() -> AborterCreate the object to assign to :attr:`aborter`.
method
src.flask.sansio.app.App.make_config(instance_relative:bool=False) -> ConfigUsed to create the config attribute by the Flask constructor.
method
src.flask.sansio.app.App.name() -> strThe name of the application.
method
src.flask.sansio.app.App.redirect(location:str, code:int=303) -> BaseResponseCreate a redirect response object.
method
src.flask.sansio.app.App.register_blueprint(blueprint:Blueprint, **options:t.Any) -> NoneRegister a :class:`~flask.Blueprint` on the application.
method
src.flask.sansio.app.App.shell_context_processor(f:T_shell_context_processor) -> T_shell_context_processorRegisters a shell context processor function.
method
src.flask.sansio.app.App.teardown_appcontext(f:T_teardown) -> T_teardownRegisters a function to be called when the app context is popped.
method
src.flask.sansio.app.App.trap_http_exception(e:Exception) -> boolChecks if an HTTP exception should be trapped or not.
method
src.flask.sansio.blueprints.Blueprint.add_app_template_filter(f:ft.TemplateFilterCallable, name:str | None=None) -> NoneRegister a function to use as a custom Jinja filter.
method
src.flask.sansio.blueprints.Blueprint.add_app_template_global(f:ft.TemplateGlobalCallable, name:str | None=None) -> NoneRegister a function to use as a custom Jinja global.
method
src.flask.sansio.blueprints.Blueprint.add_app_template_test(f:ft.TemplateTestCallable, name:str | None=None) -> NoneRegister a function to use as a custom Jinja test.
method
src.flask.sansio.blueprints.Blueprint.register_blueprint(blueprint:Blueprint, **options:t.Any) -> NoneRegister a :class:`~flask.Blueprint` on this blueprint.
class
src.flask.sessions.SecureCookieSessionBase class for sessions based on signed cookies.
class
src.flask.sessions.SessionMixinExpands a basic dictionary with session attributes.
method
src.flask.sessions.SessionMixin.permanent() -> boolThis reflects the ``'_permanent'`` key in the dict.
func
src.flask.templating.render_template(template_name_or_list:str | Template | list[str | Template], **context:t.Any) -> strRender a template by name with the given context.
method
src.flask.views.View.dispatch_request() -> ft.ResponseReturnValueThe actual view function behavior.
class
src.flask.wrappers.RequestThe request object used by default in Flask.
method
src.flask.wrappers.Request.blueprint() -> str | NoneThe registered name of the current blueprint.
method
src.flask.wrappers.Request.endpoint() -> str | NoneThe endpoint that matched the request URL.
class
src.flask.wrappers.ResponseThe response object that is used by default in Flask.
method
src.flask.wrappers.Response.max_cookie_size() -> intRead-only view of the :data:`MAX_COOKIE_SIZE` config key.
About this data
These signatures were extracted from the public source of pallets/flask
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.