Python flask 模块,Markup() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用flask.Markup()

项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
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!'
        ])
项目:WebGPIO    作者:ThisIsQasim    | 项目源码 | 文件源码
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)
项目:zanph    作者:zanph    | 项目源码 | 文件源码
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!'
        ])
项目:docker-examples    作者:geerlingguy    | 项目源码 | 文件源码
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)
项目:podigger    作者:perna    | 项目源码 | 文件源码
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")
项目:Texty    作者:sarthfrey    | 项目源码 | 文件源码
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!'
        ])
项目:tesismometro    作者:joapaspe    | 项目源码 | 文件源码
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!'
        ])
项目:CodingForLawyers    作者:KCLegalHackers    | 项目源码 | 文件源码
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
项目:isni-reconcile    作者:cmh2166    | 项目源码 | 文件源码
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!'
        ])
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
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!'
        ])
项目:Monocle    作者:Noctem    | 项目源码 | 文件源码
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)
    )
项目:bowtie    作者:jwkvam    | 项目源码 | 文件源码
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
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
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!'
        ])
项目:ctx    作者:decrypto-org    | 项目源码 | 文件源码
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
    }
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
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!'
        ])
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
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!'
        ])
项目:oniongate-web    作者:DonnchaC    | 项目源码 | 文件源码
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)
项目:tellmeabout.coffee    作者:billyfung    | 项目源码 | 文件源码
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!'
        ])
项目:veripress    作者:veripress    | 项目源码 | 文件源码
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 []))
项目:islam-buddy    作者:hamir    | 项目源码 | 文件源码
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!'
        ])
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
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!'
        ])
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
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!'
        ])
项目:My-Web-Server-Framework-With-Python2.7    作者:syjsu    | 项目源码 | 文件源码
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!'
        ])
项目:the-cartoonist    作者:torypeterschild    | 项目源码 | 文件源码
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)
项目:python_ddd_flask    作者:igorvinnicius    | 项目源码 | 文件源码
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!'
        ])
项目:QA4LOV    作者:gatemezing    | 项目源码 | 文件源码
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!'
        ])
项目:chat    作者:cambridgeltl    | 项目源码 | 文件源码
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)
项目:lalascan    作者:blackye    | 项目源码 | 文件源码
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))
项目:Sudoku-Solver    作者:ayush1997    | 项目源码 | 文件源码
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!'
        ])
项目:get5-web    作者:splewis    | 项目源码 | 文件源码
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))
项目:Flask-SocketIO    作者:cutedogspark    | 项目源码 | 文件源码
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!'
        ])
项目:compatify    作者:hatooku    | 项目源码 | 文件源码
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!'
        ])
项目:compatify    作者:hatooku    | 项目源码 | 文件源码
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!'
        ])
项目:ropi    作者:ThumbGen    | 项目源码 | 文件源码
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!'
        ])
项目:skojjt    作者:martin-green    | 项目源码 | 文件源码
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!'
        ])
项目:Data-visualization    作者:insta-code1    | 项目源码 | 文件源码
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!'
        ])
项目:zoom-autocomplete-demo    作者:kenju254    | 项目源码 | 文件源码
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!'
        ])
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
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!'
        ])
项目:a01    作者:joemcmanus    | 项目源码 | 文件源码
def clearImages():
    getPage(air, 'switch_cameramode.cgi?mode=standalone', headers)
    getPage(air, 'switch_cameramode.cgi?mode=play', headers)
    getPage(air, 'switch_cameramode.cgi?mode=playmaintenance', headers)
    bodyText=("Clearing Images on A01 <br> \n")
    response= getPage(air , 'get_imglist.cgi?DIR=/DCIM/100OLYMP', headers)
    results=re.findall("P.\d*.JPG", response)
    for result in results:
        link='exec_erase.cgi?DIR=/DCIM/100OLYMP/' + result
        print(getPage(air, link, headers))
        bodyText=bodyText + "Erasing : " + link + " <br> \n"

        #Delete local files
        if os.path.isfile('static/thumbs/'+ result):
            os.remove('static/thumbs/'+ result)
        if os.path.isfile('static/images/'+ result):
            os.remove('static/images/'+ result)

    bodyText=Markup(bodyText)
    getPage(air, 'switch_cameramode.cgi?mode=standalone', headers)
    getPage(air, 'switch_cameramode.cgi?mode=rec', headers)
    getPage(air, 'exec_takemisc.cgi?com=startliveview&port=5555', headers)
    return render_template('templatecss.html', bodyText=bodyText)
项目:noobotkit    作者:nazroll    | 项目源码 | 文件源码
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!'
        ])
项目:subroofer    作者:Sypherio    | 项目源码 | 文件源码
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!'
        ])
项目:subroofer    作者:Sypherio    | 项目源码 | 文件源码
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!'
        ])
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
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!'
        ])
项目:facebook-face-recognition    作者:mathur    | 项目源码 | 文件源码
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!'
        ])
项目:Hawkeye    作者:tozhengxq    | 项目源码 | 文件源码
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!'
        ])
项目:dodscp    作者:seancallaway    | 项目源码 | 文件源码
def home():
    results = '';
    if request.method == 'POST':
        if request.form['action'] == 'start':
            # run the start command
            results = "Starting the server...<br /><br />"
            results += check_output([app.script, "start"])
            log_action(session['uid'], 4)
            results = Markup(results.replace('\n', '<br />'))
        elif request.form['action'] == 'stop':
            # run the stop action
            results = "Stoping the server...<br /><br />"
            results += check_output([app.script, "stop"])
            log_action(session['uid'], 6)
            results = Markup(results.replace('\n', '<br />'))
        elif request.form['action'] == 'restart':
            # run the restart action
            results = "Restarting the server...<br /><br />"
            results += check_output([app.script, "restart"])
            log_action(session['uid'], 5)
            results = Markup(results.replace('\n', '<br />'))
        elif request.form['action'] == 'update':
            # run the update action
            results = "Updating the server...<br /><br />"
            results += check_output([app.script, "update"])
            log_action(session['uid'], 7)
            results = Markup(results.replace('\n', '<br />'))
        else:
            # invalid action!
            results = "INVALID ACTION!"

    g.db = connect_db()
    cur = g.db.execute('SELECT time, (SELECT users.login FROM users WHERE users.id = loggedactions.user), actions.action FROM loggedactions LEFT JOIN actions ON loggedactions.action = actions.id ORDER BY time DESC LIMIT 10;')
    actions = [dict(time=row[0], user=row[1], action=row[2]) for row in cur.fetchall()]
    g.db.close()
    return render_template('index.html', actions=actions, results=results, acp=session['priv'], username=session['username'])

#
# WELCOME PAGE
#
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def test_session_special_types(self):
        app = flask.Flask(__name__)
        app.secret_key = 'development-key'
        app.testing = True
        now = datetime.utcnow().replace(microsecond=0)
        the_uuid = uuid.uuid4()

        @app.after_request
        def modify_session(response):
            flask.session['m'] = flask.Markup('Hello!')
            flask.session['u'] = the_uuid
            flask.session['dt'] = now
            flask.session['b'] = b'\xff'
            flask.session['t'] = (1, 2, 3)
            return response

        @app.route('/')
        def dump_session_contents():
            return pickle.dumps(dict(flask.session))

        c = app.test_client()
        c.get('/')
        rv = pickle.loads(c.get('/').data)
        self.assert_equal(rv['m'], flask.Markup('Hello!'))
        self.assert_equal(type(rv['m']), flask.Markup)
        self.assert_equal(rv['dt'], now)
        self.assert_equal(rv['u'], the_uuid)
        self.assert_equal(rv['b'], b'\xff')
        self.assert_equal(type(rv['b']), bytes)
        self.assert_equal(rv['t'], (1, 2, 3))
项目:Cuneiform    作者:nervouna    | 项目源码 | 文件源码
def markup(post):
    post.set('marked_content', Markup(post.get('marked_content')))
    return post
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def test_session_special_types(self):
        app = flask.Flask(__name__)
        app.secret_key = 'development-key'
        app.testing = True
        now = datetime.utcnow().replace(microsecond=0)
        the_uuid = uuid.uuid4()

        @app.after_request
        def modify_session(response):
            flask.session['m'] = flask.Markup('Hello!')
            flask.session['u'] = the_uuid
            flask.session['dt'] = now
            flask.session['b'] = b'\xff'
            flask.session['t'] = (1, 2, 3)
            return response

        @app.route('/')
        def dump_session_contents():
            return pickle.dumps(dict(flask.session))

        c = app.test_client()
        c.get('/')
        rv = pickle.loads(c.get('/').data)
        self.assert_equal(rv['m'], flask.Markup('Hello!'))
        self.assert_equal(type(rv['m']), flask.Markup)
        self.assert_equal(rv['dt'], now)
        self.assert_equal(rv['u'], the_uuid)
        self.assert_equal(rv['b'], b'\xff')
        self.assert_equal(type(rv['b']), bytes)
        self.assert_equal(rv['t'], (1, 2, 3))
项目:quokka_ng    作者:rochacbruno    | 项目源码 | 文件源码
def render_content(self, obj):
        content = super().render_content(obj)
        if content:
            return Markup(markdown(content))
        return content or ''