neulab/docprompting-conala huggingface dataset:
flask.get_template_attribute(template_name, attribute)  
Loads a macro (or variable) a template exports. This can be used to invoke a macro from within Python code. If you for example have a template named _cider.html with the following contents: {% macro hello(name) %}Hello {{ name }}!{% endmacro %}
 You can access this from Python code like this: hello = get_template_attribute('_cider.html', 'hello')
return hello('World')
  Changelog New in version 0.2.   Parameters 
 
template_name (str) – the name of the template 
attribute (str) – the name of the variable of macro to access   Return type 
Any
flask.has_app_context()  
Works like has_request_context() but for the application context. You can also just do a boolean check on the current_app object instead.  Changelog New in version 0.9.   Return type 
bool
flask.has_request_context()  
If you have code that wants to test if a request context is there or not this function can be used. For instance, you may want to take advantage of request information if the request object is available, but fail silently if it is unavailable. class User(db.Model):

    def __init__(self, username, remote_addr=None):
        self.username = username
        if remote_addr is None and has_request_context():
            remote_addr = request.remote_addr
        self.remote_addr = remote_addr
 Alternatively you can also just test any of the context bound objects (such as request or g) for truthness: class User(db.Model):

    def __init__(self, username, remote_addr=None):
        self.username = username
        if remote_addr is None and request:
            remote_addr = request.remote_addr
        self.remote_addr = remote_addr
  Changelog New in version 0.7.   Return type 
bool
Installation Python Version We recommend using the latest version of Python. Flask supports Python 3.6 and newer. Dependencies These distributions will be installed automatically when installing Flask.  
Werkzeug implements WSGI, the standard Python interface between applications and servers. 
Jinja is a template language that renders the pages your application serves. 
MarkupSafe comes with Jinja. It escapes untrusted input when rendering templates to avoid injection attacks. 
ItsDangerous securely signs data to ensure its integrity. This is used to protect Flask’s session cookie. 
Click is a framework for writing command line applications. It provides the flask command and allows adding custom management commands.  Optional dependencies These distributions will not be installed automatically. Flask will detect and use them if you install them.  
Blinker provides support for Signals. 
python-dotenv enables support for Environment Variables From dotenv when running flask commands. 
Watchdog provides a faster, more efficient reloader for the development server.  Virtual environments Use a virtual environment to manage the dependencies for your project, both in development and in production. What problem does a virtual environment solve? The more Python projects you have, the more likely it is that you need to work with different versions of Python libraries, or even Python itself. Newer versions of libraries for one project can break compatibility in another project. Virtual environments are independent groups of Python libraries, one for each project. Packages installed for one project will not affect other projects or the operating system’s packages. Python comes bundled with the venv module to create virtual environments. Create an environment Create a project folder and a venv folder within:  
macOS/LinuxWindows


$ mkdir myproject
$ cd myproject
$ python3 -m venv venv
 

> mkdir myproject
> cd myproject
> py -3 -m venv venv
 
 Activate the environment Before you work on your project, activate the corresponding environment:  
macOS/LinuxWindows


$ . venv/bin/activate
 

> venv\Scripts\activate
 
 Your shell prompt will change to show the name of the activated environment. Install Flask Within the activated environment, use the following command to install Flask: $ pip install Flask
 Flask is now installed. Check out the Quickstart or go to the Documentation Overview.
class flask.json.JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)  
The default JSON decoder. This does not change any behavior from the built-in json.JSONDecoder. Assign a subclass of this to flask.Flask.json_decoder or flask.Blueprint.json_decoder to override the default.
class flask.json.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)  
The default JSON encoder. Handles extra types compared to the built-in json.JSONEncoder.  
datetime.datetime and datetime.date are serialized to RFC 822 strings. This is the same as the HTTP date format. 
uuid.UUID is serialized to a string. 
dataclasses.dataclass is passed to dataclasses.asdict(). 
Markup (or any object with a __html__ method) will call the __html__ method to get a string.  Assign a subclass of this to flask.Flask.json_encoder or flask.Blueprint.json_encoder to override the default.  
default(o)  
Convert o to a JSON serializable type. See json.JSONEncoder.default(). Python does not support overriding how basic types like str or list are serialized, they are handled before this method.  Parameters 
o (Any) –   Return type 
Any
default(o)  
Convert o to a JSON serializable type. See json.JSONEncoder.default(). Python does not support overriding how basic types like str or list are serialized, they are handled before this method.  Parameters 
o (Any) –   Return type 
Any
flask.json.jsonify(*args, **kwargs)  
Serialize data to JSON and wrap it in a Response with the application/json mimetype. Uses dumps() to serialize the data, but args and kwargs are treated as data rather than arguments to json.dumps().  Single argument: Treated as a single value. Multiple arguments: Treated as a list of values. jsonify(1, 2, 3) is the same as jsonify([1, 2, 3]). Keyword arguments: Treated as a dict of values. jsonify(data=data, errors=errors) is the same as jsonify({"data": data, "errors": errors}). Passing both arguments and keyword arguments is not allowed as it’s not clear what should happen.  from flask import jsonify

@app.route("/users/me")
def get_current_user():
    return jsonify(
        username=g.user.username,
        email=g.user.email,
        id=g.user.id,
    )
 Will return a JSON response like this: {
  "username": "admin",
  "email": "admin@localhost",
  "id": 42
}
 The default output omits indents and spaces after separators. In debug mode or if JSONIFY_PRETTYPRINT_REGULAR is True, the output will be formatted to be easier to read.  Changelog Changed in version 0.11: Added support for serializing top-level arrays. This introduces a security risk in ancient browsers. See JSON Security.   New in version 0.2.   Parameters 
 
args (Any) –  
kwargs (Any) –    Return type 
Response
JSONIFY_MIMETYPE  
The mimetype of jsonify responses. Default: 'application/json'
JSONIFY_PRETTYPRINT_REGULAR  
jsonify responses will be output with newlines, spaces, and indentation for easier reading by humans. Always enabled in debug mode. Default: False
class flask.json.tag.JSONTag(serializer)  
Base class for defining type tags for TaggedJSONSerializer.  Parameters 
serializer (TaggedJSONSerializer) –   Return type 
None    
check(value)  
Check if the given value should be tagged by this tag.  Parameters 
value (Any) –   Return type 
bool   
  
key: Optional[str] = None  
The tag to mark the serialized object with. If None, this tag is only used as an intermediate step during tagging. 
  
tag(value)  
Convert the value to a valid JSON type and add the tag structure around it.  Parameters 
value (Any) –   Return type 
Any   
  
to_json(value)  
Convert the Python object to an object that is a valid JSON type. The tag will be added later.  Parameters 
value (Any) –   Return type 
Any   
  
to_python(value)  
Convert the JSON representation back to the correct type. The tag will already be removed.  Parameters 
value (Any) –   Return type 
Any
check(value)  
Check if the given value should be tagged by this tag.  Parameters 
value (Any) –   Return type 
bool
key: Optional[str] = None  
The tag to mark the serialized object with. If None, this tag is only used as an intermediate step during tagging.
tag(value)  
Convert the value to a valid JSON type and add the tag structure around it.  Parameters 
value (Any) –   Return type 
Any
to_json(value)  
Convert the Python object to an object that is a valid JSON type. The tag will be added later.  Parameters 
value (Any) –   Return type 
Any
to_python(value)  
Convert the JSON representation back to the correct type. The tag will already be removed.  Parameters 
value (Any) –   Return type 
Any
JSON_AS_ASCII  
Serialize objects to ASCII-encoded JSON. If this is disabled, the JSON returned from jsonify will contain Unicode characters. This has security implications when rendering the JSON into JavaScript in templates, and should typically remain enabled. Default: True
JSON_SORT_KEYS  
Sort the keys of JSON objects alphabetically. This is useful for caching because it ensures the data is serialized the same way no matter what Python’s hash seed is. While not recommended, you can disable this for a possible performance improvement at the cost of caching. Default: True
flask.json.load(fp, app=None, **kwargs)  
Deserialize an object from JSON read from a file object. Takes the same arguments as the built-in json.load(), with some defaults from application configuration.  Parameters 
 
fp (IO[str]) – File object to read JSON from. 
app (Optional[Flask]) – Use this app’s config instead of the active app context or defaults. 
kwargs (Any) – Extra arguments passed to json.load().   Return type 
Any    Changed in version 2.0: encoding is deprecated and will be removed in Flask 2.1. The file must be text mode, or binary mode with UTF-8 bytes.
flask.json.loads(s, app=None, **kwargs)  
Deserialize an object from a string of JSON. Takes the same arguments as the built-in json.loads(), with some defaults from application configuration.  Parameters 
 
s (str) – JSON string to deserialize. 
app (Optional[Flask]) – Use this app’s config instead of the active app context or defaults. 
kwargs (Any) – Extra arguments passed to json.loads().   Return type 
Any    Changed in version 2.0: encoding is deprecated and will be removed in Flask 2.1. The data must be a string or UTF-8 bytes.   Changelog Changed in version 1.0.3: app can be passed directly, rather than requiring an app context for configuration.
flask.cli.load_dotenv(path=None)  
Load “dotenv” files in order of precedence to set environment variables. If an env var is already set it is not overwritten, so earlier files in the list are preferred over later files. This is a no-op if python-dotenv is not installed.  Parameters 
path – Load the file at this location instead of searching.  Returns 
True if a file was loaded.    Changed in version 2.0: When loading the env files, set the default encoding to UTF-8.   Changelog Changed in version 1.1.0: Returns False when python-dotenv is not installed, or when the given path isn’t a file.   New in version 1.0.
flask.make_response(*args)  
Sometimes it is necessary to set additional headers in a view. Because views do not have to return response objects but can return a value that is converted into a response object by Flask itself, it becomes tricky to add headers to it. This function can be called instead of using a return and you will get a response object which you can use to attach headers. If view looked like this and you want to add a new header: def index():
    return render_template('index.html', foo=42)
 You can now do something like this: def index():
    response = make_response(render_template('index.html', foo=42))
    response.headers['X-Parachutes'] = 'parachutes are cool'
    return response
 This function accepts the very same arguments you can return from a view function. This for example creates a response with a 404 error code: response = make_response(render_template('not_found.html'), 404)
 The other use case of this function is to force the return value of a view function into a response which is helpful with view decorators: response = make_response(view_function())
response.headers['X-Parachutes'] = 'parachutes are cool'
 Internally this function does the following things:  if no arguments are passed, it creates a new response argument if one argument is passed, flask.Flask.make_response() is invoked with it. if more than one argument is passed, the arguments are passed to the flask.Flask.make_response() function as tuple.   Changelog New in version 0.6.   Parameters 
args (Any) –   Return type 
Response
class flask.Markup(base='', encoding=None, errors='strict')  
A string that is ready to be safely inserted into an HTML or XML document, either because it was escaped or because it was marked safe. Passing an object to the constructor converts it to text and wraps it to mark it safe without escaping. To escape the text, use the escape() class method instead. >>> Markup("Hello, <em>World</em>!")
Markup('Hello, <em>World</em>!')
>>> Markup(42)
Markup('42')
>>> Markup.escape("Hello, <em>World</em>!")
Markup('Hello &lt;em&gt;World&lt;/em&gt;!')
 This implements the __html__() interface that some frameworks use. Passing an object that implements __html__() will wrap the output of that method, marking it safe. >>> class Foo:
...     def __html__(self):
...         return '<a href="/foo">foo</a>'
...
>>> Markup(Foo())
Markup('<a href="/foo">foo</a>')
 This is a subclass of str. It has the same methods, but escapes their arguments and returns a Markup instance. >>> Markup("<em>%s</em>") % ("foo & bar",)
Markup('<em>foo &amp; bar</em>')
>>> Markup("<em>Hello</em> ") + "<foo>"
Markup('<em>Hello</em> &lt;foo&gt;')
  Parameters 
 
base (Any) –  
encoding (Optional[str]) –  
errors (str) –    Return type 
Markup    
classmethod escape(s)  
Escape a string. Calls escape() and ensures that for subclasses the correct type is returned.  Parameters 
s (Any) –   Return type 
markupsafe.Markup   
  
striptags()  
unescape() the markup, remove tags, and normalize whitespace to single spaces. >>> Markup("Main &raquo;        <em>About</em>").striptags()
'Main » About'
  Return type 
str   
  
unescape()  
Convert escaped markup back into a text string. This replaces HTML entities with the characters they represent. >>> Markup("Main &raquo; <em>About</em>").unescape()
'Main » <em>About</em>'
  Return type 
str
classmethod escape(s)  
Escape a string. Calls escape() and ensures that for subclasses the correct type is returned.  Parameters 
s (Any) –   Return type 
markupsafe.Markup
striptags()  
unescape() the markup, remove tags, and normalize whitespace to single spaces. >>> Markup("Main &raquo;        <em>About</em>").striptags()
'Main » About'
  Return type 
str
unescape()  
Convert escaped markup back into a text string. This replaces HTML entities with the characters they represent. >>> Markup("Main &raquo; <em>About</em>").unescape()
'Main » <em>About</em>'
  Return type 
str
MAX_CONTENT_LENGTH  
Don’t read more than this many bytes from the incoming request data. If not set and the request does not specify a CONTENT_LENGTH, no data will be read for security. Default: None
MAX_COOKIE_SIZE  
Warn if cookie headers are larger than this many bytes. Defaults to 4093. Larger cookies may be silently ignored by browsers. Set to 0 to disable the warning.
class flask.views.MethodView  
A class-based view that dispatches request methods to the corresponding class methods. For example, if you implement a get method, it will be used to handle GET requests. class CounterAPI(MethodView):
    def get(self):
        return session.get('counter', 0)

    def post(self):
        session['counter'] = session.get('counter', 0) + 1
        return 'OK'

app.add_url_rule('/counter', view_func=CounterAPI.as_view('counter'))
  
dispatch_request(*args, **kwargs)  
Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule.  Parameters 
 
args (Any) –  
kwargs (Any) –    Return type 
Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], Union[Headers, Dict[str, Union[str, List[str], Tuple[str, …]]], List[Tuple[str, Union[str, List[str], Tuple[str, …]]]]]], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], int], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], int, Union[Headers, Dict[str, Union[str, List[str], Tuple[str, …]]], List[Tuple[str, Union[str, List[str], Tuple[str, …]]]]]], WSGIApplication]
dispatch_request(*args, **kwargs)  
Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule.  Parameters 
 
args (Any) –  
kwargs (Any) –    Return type 
Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], Union[Headers, Dict[str, Union[str, List[str], Tuple[str, …]]], List[Tuple[str, Union[str, List[str], Tuple[str, …]]]]]], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], int], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None]], int, Union[Headers, Dict[str, Union[str, List[str], Tuple[str, …]]], List[Tuple[str, Union[str, List[str], Tuple[str, …]]]]]], WSGIApplication]
class signals.Namespace  
An alias for blinker.base.Namespace if blinker is available, otherwise a dummy class that creates fake signals. This class is available for Flask extensions that want to provide the same fallback system as Flask itself.  
signal(name, doc=None)  
Creates a new signal for this namespace if blinker is available, otherwise returns a fake signal that has a send method that will do nothing but will fail with a RuntimeError for all other operations, including connecting.
signal(name, doc=None)  
Creates a new signal for this namespace if blinker is available, otherwise returns a fake signal that has a send method that will do nothing but will fail with a RuntimeError for all other operations, including connecting.
class flask.sessions.NullSession(initial=None)  
Class used to generate nicer error messages if sessions are not available. Will still allow read-only access to the empty session but fail on setting.  Parameters 
initial (Any) –   Return type 
None
flask.cli.pass_script_info(f)  
Marks a function so that an instance of ScriptInfo is passed as first argument to the click callback.  Parameters 
f (click.decorators.F) –   Return type 
click.decorators.F
PERMANENT_SESSION_LIFETIME  
If session.permanent is true, the cookie’s expiration will be set this number of seconds in the future. Can either be a datetime.timedelta or an int. Flask’s default cookie implementation validates that the cryptographic signature is not older than this value. Default: timedelta(days=31) (2678400 seconds)
PREFERRED_URL_SCHEME  
Use this scheme for generating external URLs when not in a request context. Default: 'http'
PRESERVE_CONTEXT_ON_EXCEPTION  
Don’t pop the request context when an exception occurs. If not set, this is true if DEBUG is true. This allows debuggers to introspect the request data on errors, and should normally not need to be set directly. Default: None
PROPAGATE_EXCEPTIONS  
Exceptions are re-raised rather than being handled by the app’s error handlers. If not set, this is implicitly true if TESTING or DEBUG is enabled. Default: None
flask.redirect(location, code=302, Response=None)  
Returns a response object (a WSGI application) that, if called, redirects the client to the target location. Supported codes are 301, 302, 303, 305, 307, and 308. 300 is not supported because it’s not a real redirect and 304 because it’s the answer for a request with a request with defined If-Modified-Since headers.  Changelog New in version 0.10: The class used for the Response object can now be passed in.   New in version 0.6: The location can now be a unicode string that is encoded using the iri_to_uri() function.   Parameters 
 
location (str) – the location the response should redirect to. 
code (int) – the redirect status code. defaults to 302. 
Response (class) – a Response class to use when instantiating a response. The default is werkzeug.wrappers.Response if unspecified.   Return type 
Response
flask.render_template(template_name_or_list, **context)  
Renders a template from the template folder with the given context.  Parameters 
 
template_name_or_list (Union[str, List[str]]) – the name of the template to be rendered, or an iterable with template names the first one existing will be rendered 
context (Any) – the variables that should be available in the context of the template.   Return type 
str
flask.render_template_string(source, **context)  
Renders a template from the given template source string with the given context. Template variables will be autoescaped.  Parameters 
 
source (str) – the source code of the template to be rendered 
context (Any) – the variables that should be available in the context of the template.   Return type 
str
on_json_loading_failed(e)  
Called if get_json() parsing fails and isn’t silenced. If this method returns a value, it is used as the return value for get_json(). The default implementation raises BadRequest.  Parameters 
e (Exception) –   Return type 
NoReturn
routing_exception: Optional[Exception] = None  
If matching the URL failed, this is the exception that will be raised / was raised as part of the request handling. This is usually a NotFound exception or something similar.
url_rule: Optional[Rule] = None  
The internal URL rule that matched the request. This can be useful to inspect which methods are allowed for the URL from a before/after handler (request.url_rule.methods) etc. Though if the request’s method was invalid for the URL rule, the valid list is available in routing_exception.valid_methods instead (an attribute of the Werkzeug exception MethodNotAllowed) because the request was never internally bound.  Changelog New in version 0.6.
view_args: Optional[Dict[str, Any]] = None  
A dict of view arguments that matched the request. If an exception happened when matching, this will be None.