python类Markup()的实例源码

templating.py 文件源码 项目:Flask_Blog 作者: sugarguo 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
backend.py 文件源码 项目:WebGPIO 作者: ThisIsQasim 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def main():
    now = datetime.datetime.now()
    timeString = now.strftime("%Y-%m-%d %I:%M %p")

    passer = ''
    for i in range(len(roomName)):
        passer = passer + "<p class='roomtitle'>%s</p>" % (roomName[i])
        for j in range(len(accName[i])):
            buttonHtmlName = accName[i][j].replace(" ", "<br>")
            passer = passer + "<span id='button%d%d'><button class='%s' onclick='toggle(%d,%d)'>%s</button></span>" % (i, j, accState(i,j), i, j, buttonHtmlName)

    buttonGrid = Markup(passer)
    templateData = {
        'title' : 'WebGPIO',
        'time': timeString,
        'buttons' : buttonGrid
    }
    return render_template('main.html', **templateData)
templating.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
index.py 文件源码 项目:docker-examples 作者: geerlingguy 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test():
    mysql_result = False
    # TODO REMOVE FOLLOWING LINE AFTER TESTING COMPLETE.
    db.session.query("1").from_statement("SELECT 1").all()
    try:
        if db.session.query("1").from_statement("SELECT 1").all():
            mysql_result = True
    except:
        pass

    if mysql_result:
        result = Markup('<span style="color: green;">PASS</span>')
    else:
        result = Markup('<span style="color: red;">FAIL</span>')

    # Return the page with the result.
    return render_template('index.html', result=result)
views.py 文件源码 项目:podigger 作者: perna 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def search(page=1):

    term = request.args.get('term')

    if term:
        new_term = TermRepository()
        new_term.create_or_update(term)

        episode = EpisodeRepository()
        episodes = episode.result_search_paginate(term, page, 20)
        if episodes.total:
            flash('{} resultados para {}'.format(episodes.total, term))
        else:
            message = Markup('<span>Nenhum resultado encontrado.</span> <a class="link-add-suggestion" href="/add_topic_suggestion">Gostaria de sugerir o tema?</a>')
            flash(message)
        return render_template('search.html', episodes=episodes, page="search")
    else:
        return render_template('search.html', page="search")
templating.py 文件源码 项目:Texty 作者: sarthfrey 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
templating.py 文件源码 项目:tesismometro 作者: joapaspe 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
forms.py 文件源码 项目:CodingForLawyers 作者: KCLegalHackers 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def validate(self):
    if not Form.validate(self):
      #print "not form validate"
      if "<" in self.respondent.data or \
        "<" in self.petitioner.data:
        info = Markup("<img src='/static/hackers.jpg'>")
        flash(info)
        return False
      elif self.respondent or \
        self.petitioner.data or \
        self.respondent.data:

        return True
            #print "Should return False"
      info = Markup('<h2 style="color:red"> Must complete all fields </h2>')
      flash(info)
      return False
    return True
templating.py 文件源码 项目:isni-reconcile 作者: cmh2166 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
templating.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
web.py 文件源码 项目:Monocle 作者: Noctem 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def render_map():
    css_js = ''

    if conf.LOAD_CUSTOM_CSS_FILE:
        css_js = '<link rel="stylesheet" href="static/css/custom.css">'
    if conf.LOAD_CUSTOM_JS_FILE:
        css_js += '<script type="text/javascript" src="static/js/custom.js"></script>'

    js_vars = Markup(
        "_defaultSettings['FIXED_OPACITY'] = '{:d}'; "
        "_defaultSettings['SHOW_TIMER'] = '{:d}'; "
        "_defaultSettings['TRASH_IDS'] = [{}]; ".format(conf.FIXED_OPACITY, conf.SHOW_TIMER, ', '.join(str(p_id) for p_id in conf.TRASH_IDS)))

    template = app.jinja_env.get_template('custom.html' if conf.LOAD_CUSTOM_HTML_FILE else 'newmap.html')
    return template.render(
        area_name=conf.AREA_NAME,
        map_center=center,
        map_provider_url=conf.MAP_PROVIDER_URL,
        map_provider_attribution=conf.MAP_PROVIDER_ATTRIBUTION,
        social_links=social_links(),
        init_js_vars=js_vars,
        extra_css_js=Markup(css_js)
    )
visual.py 文件源码 项目:bowtie 作者: jwkvam 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, initial=''):
        """Create a Markdown widget.

        Parameters
        ----------
        initial : str, optional
            Default markdown for the widget.

        """
        super(Markdown, self).__init__()

        self._comp = self._tag.format(
            initial=Markup(markdown(initial).replace('\n', '\\n'))
        )

    # pylint: disable=no-self-use
templating.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
context_processors.py 文件源码 项目:ctx 作者: decrypto-org 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def ctx_processor():
    ctx_object = CTX()

    def ctx_protect(secret, origin=None, alphabet=None):
        protected_secret = ctx_object.protect(secret, origin, alphabet)
        return Markup(
            "<div data-ctx-origin='{origin_id}'>{permuted}</div>".format(
                origin_id=protected_secret['origin_id'],
                permuted=quote(protected_secret['permuted'])
            )
        )

    def ctx_permutations():
        return Markup(
            "<script type='application/json' id='ctx-permutations'>{permutations}</script>".format(
                permutations=dumps(
                    ctx_object.get_permutations()
                )
            )
        )

    return {
        'ctx_protect': ctx_protect,
        'ctx_permutations': ctx_permutations
    }
templating.py 文件源码 项目:chihu 作者: yelongyu 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
templating.py 文件源码 项目:pyetje 作者: rorlika 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
dns.py 文件源码 项目:oniongate-web 作者: DonnchaC 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def build_zone_base_template(zone):
    """
    Load template files from the zone file directory and create the base NS and static records
    """
    template_data = []
    zone_dir = current_app.config['zone_dir']

    base_template = read_if_exists(os.path.join(zone_dir, 'base_zone.j2'))
    if base_template:
        template_data.append(base_template)

    zone_template = read_if_exists(os.path.join(zone_dir, '{}.zone.j2'.format(zone)))
    if zone_template:
        template_data.append(zone_template)

    template = '\n'.join(template_data)

    # Use Markup to mark the string as safe, we're not generating HTML
    return render_template_string(Markup(template), origin=zone)
templating.py 文件源码 项目:tellmeabout.coffee 作者: billyfung 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
storages.py 文件源码 项目:veripress 作者: veripress 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def search_for(self, query, include_draft=False):
        """
        Search for a query text.

        :param query: keyword to query
        :param include_draft: return draft posts/pages or not
        :return: an iterable object of posts and pages (if allowed).
        """
        query = query.lower()
        if not query:
            return []

        def contains_query_keyword(post_or_page):
            contains = query in post_or_page.title.lower() \
                       or query in Markup(
                get_parser(post_or_page.format).parse_whole(post_or_page.raw_content)
            ).striptags().lower()
            return contains

        return filter(contains_query_keyword, chain(self.get_posts(include_draft=include_draft),
                                                    self.get_pages(include_draft=include_draft)
                                                    if current_app.config['ALLOW_SEARCH_PAGES'] else []))
templating.py 文件源码 项目:islam-buddy 作者: hamir 项目源码 文件源码 阅读 71 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
templating.py 文件源码 项目:Flask-NvRay-Blog 作者: rui7157 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
templating.py 文件源码 项目:Callandtext 作者: iaora 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
templating.py 文件源码 项目:My-Web-Server-Framework-With-Python2.7 作者: syjsu 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
views.py 文件源码 项目:the-cartoonist 作者: torypeterschild 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def display():

    with app.open_resource('static/corpus000.txt') as f:
        content = f.read()

    cap = caption.Caption(content)
    cap.make()
    cartoon = cg.Cartoon(cap)

    svg_cartoon = cartoon.assemble()

    this_cartoon = Cartoon(svg_cartoon)
    db.session.add(this_cartoon)
    db.session.commit()

    drawing_markup = Markup(svg_cartoon)

    return render_template('display.html',
        drawn=True,
        svgwrite=drawing_markup)
templating.py 文件源码 项目:python_ddd_flask 作者: igorvinnicius 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
templating.py 文件源码 项目:QA4LOV 作者: gatemezing 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
views.py 文件源码 项目:chat 作者: cambridgeltl 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def pubmed(id_):
    from so2html import standoff_to_html
    from operator import itemgetter
    from itertools import groupby

    try:
        text = '\n'.join(pubmed_text_store.get_tiab(id_))
    except KeyError:
        abort(404)
    try:
        ann = pubmed_ann_store.get_spans(id_, minimize=True)
    except KeyError:
        # Assume no annotations.
        ann = []

    html = standoff_to_html(text, ann, legend=True, tooltips=True,
                            links=False, content_only=True)
    template_args = { 'documents': { id_: { 'html': Markup(html), } } }
    return render_template_with_globals('pubmed.html', template_args)
flask_paginate.py 文件源码 项目:lalascan 作者: blackye 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def links(self):
        """Get all the pagination links."""
        if self.total_pages <= 1:
            if self.show_single_page:
                return self._get_single_page_link()

            return ''

        s = [self.link_css_fmt.format(self.link_size, self.alignment)]
        s.append(self.prev_page)
        for page in self.pages:
            s.append(self.single_page(page) if page else self.gap_marker_fmt)

        s.append(self.next_page)
        s.append(self.css_end_fmt)
        if self.css_framework == 'foundation' and self.alignment:
            s.insert(0, F_ALIGNMENT.format(self.alignment))
            s.append('</div>')

        return Markup(''.join(s))
templating.py 文件源码 项目:Sudoku-Solver 作者: ayush1997 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_escaping(self):
        text = '<p>Hello World!'
        app = flask.Flask(__name__)
        @app.route('/')
        def index():
            return flask.render_template('escaping_template.html', text=text,
                                         html=flask.Markup(text))
        lines = app.test_client().get('/').data.splitlines()
        self.assert_equal(lines, [
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'<p>Hello World!',
            b'&lt;p&gt;Hello World!',
            b'<p>Hello World!'
        ])
match.py 文件源码 项目:get5-web 作者: splewis 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def match_rcon(matchid):
    match = Match.query.get_or_404(matchid)
    admintools_check(g.user, match)

    command = request.values.get('command')
    server = GameServer.query.get_or_404(match.server_id)

    if command:
        try:
            rcon_response = server.send_rcon_command(
                command, raise_errors=True)
            if rcon_response:
                rcon_response = Markup(rcon_response.replace('\n', '<br>'))
            else:
                rcon_response = 'No output'
            flash(rcon_response)
        except util.RconError as e:
            print(e)
            flash('Failed to send command: ' + str(e))

    return redirect('/match/{}'.format(matchid))


问题


面经


文章

微信
公众号

扫码关注公众号