neulab/docprompting-conala huggingface dataset:
class flask.ctx.RequestContext(app, environ, request=None, session=None)  
The request context contains all request relevant information. It is created at the beginning of the request and pushed to the _request_ctx_stack and removed at the end of it. It will create the URL adapter and request object for the WSGI environment provided. Do not attempt to use this class directly, instead use test_request_context() and request_context() to create this object. When the request context is popped, it will evaluate all the functions registered on the application for teardown execution (teardown_request()). The request context is automatically popped at the end of the request for you. In debug mode the request context is kept around if exceptions happen so that interactive debuggers have a chance to introspect the data. With 0.4 this can also be forced for requests that did not fail and outside of DEBUG mode. By setting 'flask._preserve_context' to True on the WSGI environment the context will not pop itself at the end of the request. This is used by the test_client() for example to implement the deferred cleanup functionality. You might find this helpful for unittests where you need the information from the context local around for a little longer. Make sure to properly pop() the stack yourself in that situation, otherwise your unittests will leak memory.  Parameters 
 
app (Flask) –  
environ (dict) –  
request (Optional[Request]) –  
session (Optional[SessionMixin]) –    Return type 
None    
copy()  
Creates a copy of this request context with the same request object. This can be used to move a request context to a different greenlet. Because the actual request object is the same this cannot be used to move a request context to a different thread unless access to the request object is locked.  Changelog Changed in version 1.1: The current session object is used instead of reloading the original data. This prevents flask.session pointing to an out-of-date object.   New in version 0.10.   Return type 
flask.ctx.RequestContext   
  
match_request()  
Can be overridden by a subclass to hook into the matching of the request.  Return type 
None   
  
pop(exc=<object object>)  
Pops the request context and unbinds it by doing that. This will also trigger the execution of functions registered by the teardown_request() decorator.  Changelog Changed in version 0.9: Added the exc argument.   Parameters 
exc (Optional[BaseException]) –   Return type 
None   
  
push()  
Binds the request context to the current context.  Return type 
None
copy()  
Creates a copy of this request context with the same request object. This can be used to move a request context to a different greenlet. Because the actual request object is the same this cannot be used to move a request context to a different thread unless access to the request object is locked.  Changelog Changed in version 1.1: The current session object is used instead of reloading the original data. This prevents flask.session pointing to an out-of-date object.   New in version 0.10.   Return type 
flask.ctx.RequestContext
match_request()  
Can be overridden by a subclass to hook into the matching of the request.  Return type 
None
pop(exc=<object object>)  
Pops the request context and unbinds it by doing that. This will also trigger the execution of functions registered by the teardown_request() decorator.  Changelog Changed in version 0.9: Added the exc argument.   Parameters 
exc (Optional[BaseException]) –   Return type 
None
push()  
Binds the request context to the current context.  Return type 
None
flask.safe_join(directory, *pathnames)  
Safely join zero or more untrusted path components to a base directory to avoid escaping the base directory.  Parameters 
 
directory (str) – The trusted base directory. 
pathnames (str) – The untrusted path components relative to the base directory.   Returns 
A safe path, otherwise None.  Return type 
str
class flask.cli.ScriptInfo(app_import_path=None, create_app=None, set_debug_flag=True)  
Helper object to deal with Flask applications. This is usually not necessary to interface with as it’s used internally in the dispatching to click. In future versions of Flask this object will most likely play a bigger role. Typically it’s created automatically by the FlaskGroup but you can also manually create it and pass it onwards as click object.  
app_import_path  
Optionally the import path for the Flask application. 
  
create_app  
Optionally a function that is passed the script info to create the instance of the application. 
  
data  
A dictionary with arbitrary data that can be associated with this script info. 
  
load_app()  
Loads the Flask app (if not yet loaded) and returns it. Calling this multiple times will just result in the already loaded app to be returned.
create_app  
Optionally a function that is passed the script info to create the instance of the application.
load_app()  
Loads the Flask app (if not yet loaded) and returns it. Calling this multiple times will just result in the already loaded app to be returned.
SECRET_KEY  
A secret key that will be used for securely signing the session cookie and can be used for any other security related needs by extensions or your application. It should be a long random bytes or str. For example, copy the output of this to your config: $ python -c 'import os; print(os.urandom(16))'
b'_5#y2L"F4Q8z\n\xec]/'
 Do not reveal the secret key when posting questions or committing code. Default: None
class flask.sessions.SecureCookieSession(initial=None)  
Base class for sessions based on signed cookies. This session backend will set the modified and accessed attributes. It cannot reliably track whether a session is new (vs. empty), so new remains hard coded to False.  Parameters 
initial (Any) –   Return type 
None    
accessed = False  
header, which allows caching proxies to cache different pages for different users. 
  
get(key, default=None)  
Return the value for key if key is in the dictionary, else default.  Parameters 
 
key (str) –  
default (Optional[Any]) –    Return type 
Any   
  
modified = False  
When data is changed, this is set to True. Only the session dictionary itself is tracked; if the session contains mutable data (for example a nested dict) then this must be set to True manually when modifying that data. The session cookie will only be written to the response if this is True. 
  
setdefault(key, default=None)  
Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default.  Parameters 
 
key (str) –  
default (Optional[Any]) –    Return type 
Any
accessed = False  
header, which allows caching proxies to cache different pages for different users.
get(key, default=None)  
Return the value for key if key is in the dictionary, else default.  Parameters 
 
key (str) –  
default (Optional[Any]) –    Return type 
Any
modified = False  
When data is changed, this is set to True. Only the session dictionary itself is tracked; if the session contains mutable data (for example a nested dict) then this must be set to True manually when modifying that data. The session cookie will only be written to the response if this is True.
setdefault(key, default=None)  
Insert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default.  Parameters 
 
key (str) –  
default (Optional[Any]) –    Return type 
Any
class flask.sessions.SecureCookieSessionInterface  
The default session interface that stores sessions in signed cookies through the itsdangerous module.  
static digest_method()  
the hash function to use for the signature. The default is sha1 
  
key_derivation = 'hmac'  
the name of the itsdangerous supported key derivation. The default is hmac. 
  
open_session(app, request)  
This method has to be implemented and must either return None in case the loading failed because of a configuration error or an instance of a session object which implements a dictionary like interface + the methods and attributes on SessionMixin.  Parameters 
 
app (Flask) –  
request (Request) –    Return type 
Optional[flask.sessions.SecureCookieSession]   
  
salt = 'cookie-session'  
the salt that should be applied on top of the secret key for the signing of cookie based sessions. 
  
save_session(app, session, response)  
This is called for actual sessions returned by open_session() at the end of the request. This is still called during a request context so if you absolutely need access to the request you can do that.  Parameters 
 
app (Flask) –  
session (flask.sessions.SessionMixin) –  
response (Response) –    Return type 
None   
  
serializer = <flask.json.tag.TaggedJSONSerializer object>  
A python serializer for the payload. The default is a compact JSON derived serializer with support for some extra Python types such as datetime objects or tuples. 
  
session_class  
alias of flask.sessions.SecureCookieSession
static digest_method()  
the hash function to use for the signature. The default is sha1
key_derivation = 'hmac'  
the name of the itsdangerous supported key derivation. The default is hmac.
open_session(app, request)  
This method has to be implemented and must either return None in case the loading failed because of a configuration error or an instance of a session object which implements a dictionary like interface + the methods and attributes on SessionMixin.  Parameters 
 
app (Flask) –  
request (Request) –    Return type 
Optional[flask.sessions.SecureCookieSession]
salt = 'cookie-session'  
the salt that should be applied on top of the secret key for the signing of cookie based sessions.
save_session(app, session, response)  
This is called for actual sessions returned by open_session() at the end of the request. This is still called during a request context so if you absolutely need access to the request you can do that.  Parameters 
 
app (Flask) –  
session (flask.sessions.SessionMixin) –  
response (Response) –    Return type 
None
serializer = <flask.json.tag.TaggedJSONSerializer object>  
A python serializer for the payload. The default is a compact JSON derived serializer with support for some extra Python types such as datetime objects or tuples.
SEND_FILE_MAX_AGE_DEFAULT  
When serving files, set the cache control max age to this number of seconds. Can be a datetime.timedelta or an int. Override this value on a per-file basis using get_send_file_max_age() on the application or blueprint. If None, send_file tells the browser to use conditional requests will be used instead of a timed cache, which is usually preferable. Default: None
flask.send_from_directory(directory, path, filename=None, **kwargs)  
Send a file from within a directory using send_file(). @app.route("/uploads/<path:name>")
def download_file(name):
    return send_from_directory(
        app.config['UPLOAD_FOLDER'], name, as_attachment=True
    )
 This is a secure way to serve files from a folder, such as static files or uploads. Uses safe_join() to ensure the path coming from the client is not maliciously crafted to point outside the specified directory. If the final path does not point to an existing regular file, raises a 404 NotFound error.  Parameters 
 
directory (str) – The directory that path must be located under. 
path (str) – The path to the file to send, relative to directory. 
kwargs (Any) – Arguments to pass to send_file(). 
filename (Optional[str]) –    Return type 
Response    Changed in version 2.0: path replaces the filename parameter.   New in version 2.0: Moved the implementation to Werkzeug. This is now a wrapper to pass some Flask-specific arguments.   Changelog New in version 0.5.
SERVER_NAME  
Inform the application what host and port it is bound to. Required for subdomain route matching support. If set, will be used for the session cookie domain if SESSION_COOKIE_DOMAIN is not set. Modern web browsers will not allow setting cookies for domains without a dot. To use a domain locally, add any names that should route to the app to your hosts file. 127.0.0.1 localhost.dev
 If set, url_for can generate external URLs with only an application context instead of a request context. Default: None
class flask.session  
The session object works pretty much like an ordinary dict, with the difference that it keeps track of modifications. This is a proxy. See Notes On Proxies for more information. The following attributes are interesting:  
new  
True if the session is new, False otherwise. 
  
modified  
True if the session object detected a modification. Be advised that modifications on mutable structures are not picked up automatically, in that situation you have to explicitly set the attribute to True yourself. Here an example: # this change is not picked up because a mutable object (here
# a list) is changed.
session['objects'].append(42)
# so mark it as modified yourself
session.modified = True
 
  
permanent  
If set to True the session lives for permanent_session_lifetime seconds. The default is 31 days. If set to False (which is the default) the session will be deleted when the user closes the browser.
modified  
True if the session object detected a modification. Be advised that modifications on mutable structures are not picked up automatically, in that situation you have to explicitly set the attribute to True yourself. Here an example: # this change is not picked up because a mutable object (here
# a list) is changed.
session['objects'].append(42)
# so mark it as modified yourself
session.modified = True
permanent  
If set to True the session lives for permanent_session_lifetime seconds. The default is 31 days. If set to False (which is the default) the session will be deleted when the user closes the browser.
get_cookie_domain(app)  
Returns the domain that should be set for the session cookie. Uses SESSION_COOKIE_DOMAIN if it is configured, otherwise falls back to detecting the domain based on SERVER_NAME. Once detected (or if not set at all), SESSION_COOKIE_DOMAIN is updated to avoid re-running the logic.  Parameters 
app (Flask) –   Return type 
Optional[str]
get_cookie_httponly(app)  
Returns True if the session cookie should be httponly. This currently just returns the value of the SESSION_COOKIE_HTTPONLY config var.  Parameters 
app (Flask) –   Return type 
bool
get_cookie_name(app)  
Returns the name of the session cookie. Uses app.session_cookie_name which is set to SESSION_COOKIE_NAME  Parameters 
app (Flask) –   Return type 
str
get_cookie_path(app)  
Returns the path for which the cookie should be valid. The default implementation uses the value from the SESSION_COOKIE_PATH config var if it’s set, and falls back to APPLICATION_ROOT or uses / if it’s None.  Parameters 
app (Flask) –   Return type 
str
get_cookie_samesite(app)  
Return 'Strict' or 'Lax' if the cookie should use the SameSite attribute. This currently just returns the value of the SESSION_COOKIE_SAMESITE setting.  Parameters 
app (Flask) –   Return type 
str
get_cookie_secure(app)  
Returns True if the cookie should be secure. This currently just returns the value of the SESSION_COOKIE_SECURE setting.  Parameters 
app (Flask) –   Return type 
bool
get_expiration_time(app, session)  
A helper method that returns an expiration date for the session or None if the session is linked to the browser session. The default implementation returns now + the permanent session lifetime configured on the application.  Parameters 
 
app (Flask) –  
session (flask.sessions.SessionMixin) –    Return type 
Optional[datetime.datetime]
is_null_session(obj)  
Checks if a given object is a null session. Null sessions are not asked to be saved. This checks if the object is an instance of null_session_class by default.  Parameters 
obj (object) –   Return type 
bool
make_null_session(app)  
Creates a null session which acts as a replacement object if the real session support could not be loaded due to a configuration error. This mainly aids the user experience because the job of the null session is to still support lookup without complaining but modifications are answered with a helpful error message of what failed. This creates an instance of null_session_class by default.  Parameters 
app (Flask) –   Return type 
flask.sessions.NullSession
null_session_class  
make_null_session() will look here for the class that should be created when a null session is requested. Likewise the is_null_session() method will perform a typecheck against this type. alias of flask.sessions.NullSession
open_session(app, request)  
This method has to be implemented and must either return None in case the loading failed because of a configuration error or an instance of a session object which implements a dictionary like interface + the methods and attributes on SessionMixin.  Parameters 
 
app (Flask) –  
request (Request) –    Return type 
Optional[flask.sessions.SessionMixin]
pickle_based = False  
A flag that indicates if the session interface is pickle based. This can be used by Flask extensions to make a decision in regards to how to deal with the session object.  Changelog New in version 0.10.
should_set_cookie(app, session)  
Used by session backends to determine if a Set-Cookie header should be set for this session cookie for this response. If the session has been modified, the cookie is set. If the session is permanent and the SESSION_REFRESH_EACH_REQUEST config is true, the cookie is always set. This check is usually skipped if the session was deleted.  Changelog New in version 0.11.   Parameters 
 
app (Flask) –  
session (flask.sessions.SessionMixin) –    Return type 
bool
class flask.sessions.SessionMixin  
Expands a basic dictionary with session attributes.  
accessed = True  
Some implementations can detect when session data is read or written and set this when that happens. The mixin default is hard coded to True. 
  
modified = True  
Some implementations can detect changes to the session and set this when that happens. The mixin default is hard coded to True. 
  
property permanent: bool  
This reflects the '_permanent' key in the dict.
accessed = True  
Some implementations can detect when session data is read or written and set this when that happens. The mixin default is hard coded to True.
modified = True  
Some implementations can detect changes to the session and set this when that happens. The mixin default is hard coded to True.
SESSION_COOKIE_DOMAIN  
The domain match rule that the session cookie will be valid for. If not set, the cookie will be valid for all subdomains of SERVER_NAME. If False, the cookie’s domain will not be set. Default: None
SESSION_COOKIE_HTTPONLY  
Browsers will not allow JavaScript access to cookies marked as “HTTP only” for security. Default: True
SESSION_COOKIE_NAME  
The name of the session cookie. Can be changed in case you already have a cookie with the same name. Default: 'session'
SESSION_COOKIE_PATH  
The path that the session cookie will be valid for. If not set, the cookie will be valid underneath APPLICATION_ROOT or / if that is not set. Default: None
SESSION_COOKIE_SAMESITE  
Restrict how cookies are sent with requests from external sites. Can be set to 'Lax' (recommended) or 'Strict'. See Set-Cookie options. Default: None  Changelog New in version 1.0.
SESSION_COOKIE_SECURE  
Browsers will only send cookies with requests over HTTPS if the cookie is marked “secure”. The application must be served over HTTPS for this to make sense. Default: False
SESSION_REFRESH_EACH_REQUEST  
Control whether the cookie is sent with every response when session.permanent is true. Sending the cookie every time (the default) can more reliably keep the session from expiring, but uses more bandwidth. Non-permanent sessions are not affected. Default: True
flask.stream_with_context(generator_or_function)  
Request contexts disappear when the response is started on the server. This is done for efficiency reasons and to make it less likely to encounter memory leaks with badly written WSGI middlewares. The downside is that if you are using streamed responses, the generator cannot access request bound information any more. This function however can help you keep the context around for longer: from flask import stream_with_context, request, Response

@app.route('/stream')
def streamed_response():
    @stream_with_context
    def generate():
        yield 'Hello '
        yield request.args['name']
        yield '!'
    return Response(generate())
 Alternatively it can also be used around a specific generator: from flask import stream_with_context, request, Response

@app.route('/stream')
def streamed_response():
    def generate():
        yield 'Hello '
        yield request.args['name']
        yield '!'
    return Response(stream_with_context(generate()))
  Changelog New in version 0.9.   Parameters 
generator_or_function (Union[Generator, Callable]) –   Return type 
Generator
class flask.json.tag.TaggedJSONSerializer  
Serializer that uses a tag system to compactly represent objects that are not JSON types. Passed as the intermediate serializer to itsdangerous.Serializer. The following extra types are supported:  dict tuple bytes Markup UUID datetime   Return type 
None    
default_tags = [<class 'flask.json.tag.TagDict'>, <class 'flask.json.tag.PassDict'>, <class 'flask.json.tag.TagTuple'>, <class 'flask.json.tag.PassList'>, <class 'flask.json.tag.TagBytes'>, <class 'flask.json.tag.TagMarkup'>, <class 'flask.json.tag.TagUUID'>, <class 'flask.json.tag.TagDateTime'>]  
Tag classes to bind when creating the serializer. Other tags can be added later using register(). 
  
dumps(value)  
Tag the value and dump it to a compact JSON string.  Parameters 
value (Any) –   Return type 
str   
  
loads(value)  
Load data from a JSON string and deserialized any tagged objects.  Parameters 
value (str) –   Return type 
Any   
  
register(tag_class, force=False, index=None)  
Register a new tag with this serializer.  Parameters 
 
tag_class (Type[flask.json.tag.JSONTag]) – tag class to register. Will be instantiated with this serializer instance. 
force (bool) – overwrite an existing tag. If false (default), a KeyError is raised. 
index (Optional[int]) – index to insert the new tag in the tag order. Useful when the new tag is a special case of an existing tag. If None (default), the tag is appended to the end of the order.   Raises 
KeyError – if the tag key is already registered and force is not true.  Return type 
None   
  
tag(value)  
Convert a value to a tagged representation if necessary.  Parameters 
value (Any) –   Return type 
Dict[str, Any]   
  
untag(value)  
Convert a tagged representation back to the original type.  Parameters 
value (Dict[str, Any]) –   Return type 
Any
default_tags = [<class 'flask.json.tag.TagDict'>, <class 'flask.json.tag.PassDict'>, <class 'flask.json.tag.TagTuple'>, <class 'flask.json.tag.PassList'>, <class 'flask.json.tag.TagBytes'>, <class 'flask.json.tag.TagMarkup'>, <class 'flask.json.tag.TagUUID'>, <class 'flask.json.tag.TagDateTime'>]  
Tag classes to bind when creating the serializer. Other tags can be added later using register().
dumps(value)  
Tag the value and dump it to a compact JSON string.  Parameters 
value (Any) –   Return type 
str
loads(value)  
Load data from a JSON string and deserialized any tagged objects.  Parameters 
value (str) –   Return type 
Any
register(tag_class, force=False, index=None)  
Register a new tag with this serializer.  Parameters 
 
tag_class (Type[flask.json.tag.JSONTag]) – tag class to register. Will be instantiated with this serializer instance. 
force (bool) – overwrite an existing tag. If false (default), a KeyError is raised. 
index (Optional[int]) – index to insert the new tag in the tag order. Useful when the new tag is a special case of an existing tag. If None (default), the tag is appended to the end of the order.   Raises 
KeyError – if the tag key is already registered and force is not true.  Return type 
None
tag(value)  
Convert a value to a tagged representation if necessary.  Parameters 
value (Any) –   Return type 
Dict[str, Any]
untag(value)  
Convert a tagged representation back to the original type.  Parameters 
value (Dict[str, Any]) –   Return type 
Any
TEMPLATES_AUTO_RELOAD  
Reload templates when they are changed. If not set, it will be enabled in debug mode. Default: None