neulab/docprompting-conala huggingface dataset:
template_global(name=None)  
A decorator that is used to register a custom template global function. You can specify a name for the global function, otherwise the function name will be used. Example: @app.template_global()
def double(n):
    return 2 * n
  Changelog New in version 0.10.   Parameters 
name (Optional[str]) – the optional name of the global function, otherwise the function name will be used.  Return type 
Callable
flask.template_rendered  
This signal is sent when a template was successfully rendered. The signal is invoked with the instance of the template as template and the context as dictionary (named context). Example subscriber: def log_template_renders(sender, template, context, **extra):
    sender.logger.debug('Rendering template "%s" with context %s',
                        template.name or 'string template',
                        context)

from flask import template_rendered
template_rendered.connect(log_template_renders, app)
template_test(name=None)  
A decorator that is used to register custom template test. You can specify a name for the test, otherwise the function name will be used. Example: @app.template_test()
def is_prime(n):
    if n == 2:
        return True
    for i in range(2, int(math.ceil(math.sqrt(n))) + 1):
        if n % i == 0:
            return False
    return True
  Changelog New in version 0.10.   Parameters 
name (Optional[str]) – the optional name of the test, otherwise the function name will be used.  Return type 
Callable
testing  
The testing flag. Set this to True to enable the test mode of Flask extensions (and in the future probably also Flask itself). For example this might activate test helpers that have an additional runtime cost which should not be enabled by default. If this is enabled and PROPAGATE_EXCEPTIONS is not changed from the default it’s implicitly enabled. This attribute can also be configured from the config with the TESTING configuration key. Defaults to False.
test_client(use_cookies=True, **kwargs)  
Creates a test client for this application. For information about unit testing head over to Testing Flask Applications. Note that if you are testing for assertions or exceptions in your application code, you must set app.testing = True in order for the exceptions to propagate to the test client. Otherwise, the exception will be handled by the application (not visible to the test client) and the only indication of an AssertionError or other exception will be a 500 status code response to the test client. See the testing attribute. For example: app.testing = True
client = app.test_client()
 The test client can be used in a with block to defer the closing down of the context until the end of the with block. This is useful if you want to access the context locals for testing: with app.test_client() as c:
    rv = c.get('/?vodka=42')
    assert request.args['vodka'] == '42'
 Additionally, you may pass optional keyword arguments that will then be passed to the application’s test_client_class constructor. For example: from flask.testing import FlaskClient

class CustomClient(FlaskClient):
    def __init__(self, *args, **kwargs):
        self._authentication = kwargs.pop("authentication")
        super(CustomClient,self).__init__( *args, **kwargs)

app.test_client_class = CustomClient
client = app.test_client(authentication='Basic ....')
 See FlaskClient for more information.  Changelog Changed in version 0.11: Added **kwargs to support passing additional keyword arguments to the constructor of test_client_class.   New in version 0.7: The use_cookies parameter was added as well as the ability to override the client to be used by setting the test_client_class attribute.   Changed in version 0.4: added support for with block usage for the client.   Parameters 
 
use_cookies (bool) –  
kwargs (Any) –    Return type 
FlaskClient
test_client_class: Optional[Type[FlaskClient]] = None  
the test client that is used with when test_client is used.  Changelog New in version 0.7.
test_cli_runner(**kwargs)  
Create a CLI runner for testing CLI commands. See Testing CLI Commands. Returns an instance of test_cli_runner_class, by default FlaskCliRunner. The Flask app object is passed as the first argument.  Changelog New in version 1.0.   Parameters 
kwargs (Any) –   Return type 
FlaskCliRunner
test_cli_runner_class: Optional[Type[FlaskCliRunner]] = None  
The CliRunner subclass, by default FlaskCliRunner that is used by test_cli_runner(). Its __init__ method should take a Flask app object as the first argument.  Changelog New in version 1.0.
test_request_context(*args, **kwargs)  
Create a RequestContext for a WSGI environment created from the given values. This is mostly useful during testing, where you may want to run a function that uses request data without dispatching a full request. See The Request Context. Use a with block to push the context, which will make request point at the request for the created environment. with test_request_context(...):
    generate_report()
 When using the shell, it may be easier to push and pop the context manually to avoid indentation. ctx = app.test_request_context(...)
ctx.push()
...
ctx.pop()
 Takes the same arguments as Werkzeug’s EnvironBuilder, with some defaults from the application. See the linked Werkzeug docs for most of the available arguments. Flask-specific behavior is listed here.  Parameters 
 
path – URL path being requested. 
base_url – Base URL where the app is being served, which path is relative to. If not given, built from PREFERRED_URL_SCHEME, subdomain, SERVER_NAME, and APPLICATION_ROOT. 
subdomain – Subdomain name to append to SERVER_NAME. 
url_scheme – Scheme to use instead of PREFERRED_URL_SCHEME. 
data – The request body, either as a string or a dict of form keys and values. 
json – If given, this is serialized as JSON and passed as data. Also defaults content_type to application/json. 
args (Any) – other positional arguments passed to EnvironBuilder. 
kwargs (Any) – other keyword arguments passed to EnvironBuilder.   Return type 
flask.ctx.RequestContext
trap_http_exception(e)  
Checks if an HTTP exception should be trapped or not. By default this will return False for all exceptions except for a bad request key error if TRAP_BAD_REQUEST_ERRORS is set to True. It also returns True if TRAP_HTTP_EXCEPTIONS is set to True. This is called for all HTTP exceptions raised by a view function. If it returns True for any exception the error handler for this exception is not called and it shows up as regular exception in the traceback. This is helpful for debugging implicitly raised HTTP exceptions.  Changelog Changed in version 1.0: Bad request errors are not trapped by default in debug mode.   New in version 0.8.   Parameters 
e (Exception) –   Return type 
bool
update_template_context(context)  
Update the template context with some commonly used variables. This injects request, session, config and g into the template context as well as everything template context processors want to inject. Note that the as of Flask 0.6, the original values in the context will not be overridden if a context processor decides to return a value with the same key.  Parameters 
context (dict) – the context as a dictionary that is updated in place to add extra variables.  Return type 
None
url_build_error_handlers: t.List[t.Callable[[Exception, str, dict], str]]  
A list of functions that are called when url_for() raises a BuildError. Each function registered here is called with error, endpoint and values. If a function returns None or raises a BuildError the next function is tried.  Changelog New in version 0.9.
url_map  
The Map for this instance. You can use this to change the routing converters after the class was created but before any routes are connected. Example: from werkzeug.routing import BaseConverter

class ListConverter(BaseConverter):
    def to_python(self, value):
        return value.split(',')
    def to_url(self, values):
        return ','.join(super(ListConverter, self).to_url(value)
                        for value in values)

app = Flask(__name__)
app.url_map.converters['list'] = ListConverter
use_x_sendfile  
Enable this if you want to use the X-Sendfile feature. Keep in mind that the server has to support this. This only affects files sent with the send_file() method.  Changelog New in version 0.2.  This attribute can also be configured from the config with the USE_X_SENDFILE configuration key. Defaults to False.
wsgi_app(environ, start_response)  
The actual WSGI application. This is not implemented in __call__() so that middlewares can be applied without losing a reference to the app object. Instead of doing this: app = MyMiddleware(app)
 It’s a better idea to do this instead: app.wsgi_app = MyMiddleware(app.wsgi_app)
 Then you still have the original application object around and can continue to call methods on it.  Changelog Changed in version 0.7: Teardown events for the request and app contexts are called even if an unhandled error occurs. Other events may not be called depending on when an error occurs during dispatch. See Callbacks and Errors.   Parameters 
 
environ (dict) – A WSGI environment. 
start_response (Callable) – A callable accepting a status code, a list of headers, and an optional exception context to start the response.   Return type 
Any
flask._app_ctx_stack  
The internal LocalStack that holds AppContext instances. Typically, the current_app and g proxies should be accessed instead of the stack. Extensions can access the contexts on the stack as a namespace to store data.  Changelog New in version 0.9.
flask._request_ctx_stack  
The internal LocalStack that holds RequestContext instances. Typically, the request and session proxies should be accessed instead of the stack. It may be useful to access the stack in extension code. The following attributes are always present on each layer of the stack:  
app 

the active Flask application.  
url_adapter 

the URL adapter that was used to match the request.  
request 

the current request object.  
session 

the active session object.  
g 

an object with all the attributes of the flask.g object.  
flashes 

an internal cache for the flashed messages.   Example usage: from flask import _request_ctx_stack

def get_session():
    ctx = _request_ctx_stack.top
    if ctx is not None:
        return ctx.session
class flask.testing.FlaskClient(*args, **kwargs)  
Works like a regular Werkzeug test client but has some knowledge about how Flask works to defer the cleanup of the request context stack to the end of a with body when used in a with statement. For general information about how to use this class refer to werkzeug.test.Client.  Changelog Changed in version 0.12: app.test_client() includes preset default environment, which can be set after instantiation of the app.test_client() object in client.environ_base.  Basic usage is outlined in the Testing Flask Applications chapter.  Parameters 
 
args (Any) –  
kwargs (Any) –    Return type 
None    
open(*args, as_tuple=False, buffered=False, follow_redirects=False, **kwargs)  
Generate an environ dict from the given arguments, make a request to the application using it, and return the response.  Parameters 
 
args (Any) – Passed to EnvironBuilder to create the environ for the request. If a single arg is passed, it can be an existing EnvironBuilder or an environ dict. 
buffered (bool) – Convert the iterator returned by the app into a list. If the iterator has a close() method, it is called automatically. 
follow_redirects (bool) – Make additional requests to follow HTTP redirects until a non-redirect status is returned. TestResponse.history lists the intermediate responses. 
as_tuple (bool) –  
kwargs (Any) –    Return type 
Response    Changed in version 2.0: as_tuple is deprecated and will be removed in Werkzeug 2.1. Use TestResponse.request and request.environ instead.   Changed in version 2.0: The request input stream is closed when calling response.close(). Input streams for redirects are automatically closed.   Changelog Changed in version 0.5: If a dict is provided as file in the dict for the data parameter the content type has to be called content_type instead of mimetype. This change was made for consistency with werkzeug.FileWrapper.   Changed in version 0.5: Added the follow_redirects parameter.  

  
session_transaction(*args, **kwargs)  
When used in combination with a with statement this opens a session transaction. This can be used to modify the session that the test client uses. Once the with block is left the session is stored back. with client.session_transaction() as session:
    session['value'] = 42
 Internally this is implemented by going through a temporary test request context and since session handling could depend on request variables this function accepts the same arguments as test_request_context() which are directly passed through.  Parameters 
 
args (Any) –  
kwargs (Any) –    Return type 
Generator[flask.sessions.SessionMixin, None, None]
open(*args, as_tuple=False, buffered=False, follow_redirects=False, **kwargs)  
Generate an environ dict from the given arguments, make a request to the application using it, and return the response.  Parameters 
 
args (Any) – Passed to EnvironBuilder to create the environ for the request. If a single arg is passed, it can be an existing EnvironBuilder or an environ dict. 
buffered (bool) – Convert the iterator returned by the app into a list. If the iterator has a close() method, it is called automatically. 
follow_redirects (bool) – Make additional requests to follow HTTP redirects until a non-redirect status is returned. TestResponse.history lists the intermediate responses. 
as_tuple (bool) –  
kwargs (Any) –    Return type 
Response    Changed in version 2.0: as_tuple is deprecated and will be removed in Werkzeug 2.1. Use TestResponse.request and request.environ instead.   Changed in version 2.0: The request input stream is closed when calling response.close(). Input streams for redirects are automatically closed.   Changelog Changed in version 0.5: If a dict is provided as file in the dict for the data parameter the content type has to be called content_type instead of mimetype. This change was made for consistency with werkzeug.FileWrapper.   Changed in version 0.5: Added the follow_redirects parameter.
session_transaction(*args, **kwargs)  
When used in combination with a with statement this opens a session transaction. This can be used to modify the session that the test client uses. Once the with block is left the session is stored back. with client.session_transaction() as session:
    session['value'] = 42
 Internally this is implemented by going through a temporary test request context and since session handling could depend on request variables this function accepts the same arguments as test_request_context() which are directly passed through.  Parameters 
 
args (Any) –  
kwargs (Any) –    Return type 
Generator[flask.sessions.SessionMixin, None, None]
class flask.testing.FlaskCliRunner(app, **kwargs)  
A CliRunner for testing a Flask app’s CLI commands. Typically created using test_cli_runner(). See Testing CLI Commands.  Parameters 
 
app (Flask) –  
kwargs (Any) –    Return type 
None    
invoke(cli=None, args=None, **kwargs)  
Invokes a CLI command in an isolated environment. See CliRunner.invoke for full method documentation. See Testing CLI Commands for examples. If the obj argument is not given, passes an instance of ScriptInfo that knows how to load the Flask app being tested.  Parameters 
 
cli (Optional[Any]) – Command object to invoke. Default is the app’s cli group. 
args (Optional[Any]) – List of strings to invoke the command with. 
kwargs (Any) –    Returns 
a Result object.  Return type 
Any
invoke(cli=None, args=None, **kwargs)  
Invokes a CLI command in an isolated environment. See CliRunner.invoke for full method documentation. See Testing CLI Commands for examples. If the obj argument is not given, passes an instance of ScriptInfo that knows how to load the Flask app being tested.  Parameters 
 
cli (Optional[Any]) – Command object to invoke. Default is the app’s cli group. 
args (Optional[Any]) – List of strings to invoke the command with. 
kwargs (Any) –    Returns 
a Result object.  Return type 
Any
class flask.cli.FlaskGroup(add_default_commands=True, create_app=None, add_version_option=True, load_dotenv=True, set_debug_flag=True, **extra)  
Special subclass of the AppGroup group that supports loading more commands from the configured Flask app. Normally a developer does not have to interface with this class but there are some very advanced use cases for which it makes sense to create an instance of this. see Custom Scripts.  Parameters 
 
add_default_commands – if this is True then the default run and shell commands will be added. 
add_version_option – adds the --version option. 
create_app – an optional callback that is passed the script info and returns the loaded app. 
load_dotenv – Load the nearest .env and .flaskenv files to set environment variables. Will also change the working directory to the directory containing the first file found. 
set_debug_flag – Set the app’s debug flag based on the active environment     Changelog Changed in version 1.0: If installed, python-dotenv will be used to load environment variables from .env and .flaskenv files.   
get_command(ctx, name)  
Given a context and a command name, this returns a Command object if it exists or returns None. 
  
list_commands(ctx)  
Returns a list of subcommand names in the order they should appear. 
  
main(*args, **kwargs)  
This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, SystemExit needs to be caught. This method is also available by directly calling the instance of a Command.  Parameters 
 
args – the arguments that should be used for parsing. If not provided, sys.argv[1:] is used. 
prog_name – the program name that should be used. By default the program name is constructed by taking the file name from sys.argv[0]. 
complete_var – the environment variable that controls the bash completion support. The default is "_<prog_name>_COMPLETE" with prog_name in uppercase. 
standalone_mode – the default behavior is to invoke the script in standalone mode. Click will then handle exceptions and convert them into error messages and the function will never return but shut down the interpreter. If this is set to False they will be propagated to the caller and the return value of this function is the return value of invoke(). 
extra – extra keyword arguments are forwarded to the context constructor. See Context for more information.     Changed in version 8.0: When taking arguments from sys.argv on Windows, glob patterns, user dir, and env vars are expanded.   Changed in version 3.0: Added the standalone_mode parameter.
get_command(ctx, name)  
Given a context and a command name, this returns a Command object if it exists or returns None.
list_commands(ctx)  
Returns a list of subcommand names in the order they should appear.
main(*args, **kwargs)  
This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, SystemExit needs to be caught. This method is also available by directly calling the instance of a Command.  Parameters 
 
args – the arguments that should be used for parsing. If not provided, sys.argv[1:] is used. 
prog_name – the program name that should be used. By default the program name is constructed by taking the file name from sys.argv[0]. 
complete_var – the environment variable that controls the bash completion support. The default is "_<prog_name>_COMPLETE" with prog_name in uppercase. 
standalone_mode – the default behavior is to invoke the script in standalone mode. Click will then handle exceptions and convert them into error messages and the function will never return but shut down the interpreter. If this is set to False they will be propagated to the caller and the return value of this function is the return value of invoke(). 
extra – extra keyword arguments are forwarded to the context constructor. See Context for more information.     Changed in version 8.0: When taking arguments from sys.argv on Windows, glob patterns, user dir, and env vars are expanded.   Changed in version 3.0: Added the standalone_mode parameter.
Foreword Read this before you get started with Flask. This hopefully answers some questions about the purpose and goals of the project, and when you should or should not be using it. What does “micro” mean? “Micro” does not mean that your whole web application has to fit into a single Python file (although it certainly can), nor does it mean that Flask is lacking in functionality. The “micro” in microframework means Flask aims to keep the core simple but extensible. Flask won’t make many decisions for you, such as what database to use. Those decisions that it does make, such as what templating engine to use, are easy to change. Everything else is up to you, so that Flask can be everything you need and nothing you don’t. By default, Flask does not include a database abstraction layer, form validation or anything else where different libraries already exist that can handle that. Instead, Flask supports extensions to add such functionality to your application as if it was implemented in Flask itself. Numerous extensions provide database integration, form validation, upload handling, various open authentication technologies, and more. Flask may be “micro”, but it’s ready for production use on a variety of needs. Configuration and Conventions Flask has many configuration values, with sensible defaults, and a few conventions when getting started. By convention, templates and static files are stored in subdirectories within the application’s Python source tree, with the names templates and static respectively. While this can be changed, you usually don’t have to, especially when getting started. Growing with Flask Once you have Flask up and running, you’ll find a variety of extensions available in the community to integrate your project for production. As your codebase grows, you are free to make the design decisions appropriate for your project. Flask will continue to provide a very simple glue layer to the best that Python has to offer. You can implement advanced patterns in SQLAlchemy or another database tool, introduce non-relational data persistence as appropriate, and take advantage of framework-agnostic tools built for WSGI, the Python web interface. Flask includes many hooks to customize its behavior. Should you need more customization, the Flask class is built for subclassing. If you are interested in that, check out the Becoming Big chapter. If you are curious about the Flask design principles, head over to the section about Design Decisions in Flask.
flask.get_flashed_messages(with_categories=False, category_filter=())  
Pulls all flashed messages from the session and returns them. Further calls in the same request to the function will return the same messages. By default just the messages are returned, but when with_categories is set to True, the return value will be a list of tuples in the form (category, message) instead. Filter the flashed messages to one or more categories by providing those categories in category_filter. This allows rendering categories in separate html blocks. The with_categories and category_filter arguments are distinct:  
with_categories controls whether categories are returned with message text (True gives a tuple, where False gives just the message text). 
category_filter filters the messages down to only those matching the provided categories.  See Message Flashing for examples.  Changelog Changed in version 0.9: category_filter parameter added.   Changed in version 0.3: with_categories parameter added.   Parameters 
 
with_categories (bool) – set to True to also receive categories. 
category_filter (Iterable[str]) – filter of categories to limit return values. Only categories in the list will be returned.   Return type 
Union[List[str], List[Tuple[str, str]]]