Skip to content
Myr

add import for escape in quickstart

Before adoption: this commit came in with the history the project adopted, so no landing records it.

import escape from markupsafe instead of flask

authored by Grey Li · committed by David Lord · parent ef27c1b · Browse files · 1 file+8 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−4 removed

  • other:+8 added−4 removed

1 file+8 added−4 removed

modified:docs/quickstart.rst+8 added-4 removed
198 unmodified lines
199``<variable_name>``. Your function then receives the ``<variable_name>``200as a keyword argument. Optionally, you can use a converter to specify the type201of the argument like ``<converter:variable_name>``. ::202203 from markupsafe import escape204205 @app.route('/user/<username>')206 def show_user_profile(username):207 # show the user profile for that user208 return 'User %s' % escape(username)
73 unmodified lines
282Python shell. See :ref:`context-locals`.283284.. code-block:: python285284 from flask import Flask, escape, url_for286 from flask import Flask, url_for287 from markupsafe import escape288289 app = Flask(__name__)290291 @app.route('/')
129 unmodified lines
421markup to HTML) you can mark it as safe by using the422:class:`~jinja2.Markup` class or by using the ``|safe`` filter in the423template. Head over to the Jinja 2 documentation for more examples.424422Here is a basic introduction to how the :class:`~jinja2.Markup` class works::425Here is a basic introduction to how the :class:`~markupsafe.Markup` class works::426424 >>> from flask import Markup427 >>> from markupsafe import Markup428 >>> Markup('<strong>Hello %s!</strong>') % '<blink>hacker</blink>'429 Markup(u'<strong>Hello &lt;blink&gt;hacker&lt;/blink&gt;!</strong>')430 >>> Markup.escape('<blink>hacker</blink>')431 Markup(u'&lt;blink&gt;hacker&lt;/blink&gt;')
338 unmodified lines
770771In order to use sessions you have to set a secret key. Here is how772sessions work::773771 from flask import Flask, session, redirect, url_for, escape, request774 from flask import Flask, session, redirect, url_for, request775 from markupsafe import escape776777 app = Flask(__name__)778779 # Set the secret key to some random bytes. Keep this really secret!
124 unmodified lines