How to use the flask.render_template function in Flask

To help you get started, we’ve selected a few Flask examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nprapps / dailygraphics / app.py View on Github external
templates = glob('%s/*' % app_config.TEMPLATES_PATH)

    for template in templates:
        name = template.split('%s/' % app_config.TEMPLATES_PATH)[1]

        if name.startswith('_'):
            continue

        context['templates'].append(name)

    context['templates'].sort()

    context['templates_count'] = len(context['templates'])

    return make_response(render_template('index.html', **context))
github mark-church / docker-pets / web / admin.py View on Github external
@app.route('/admin', methods=['POST','GET'])
def console():
    admin_id = request.cookies.get('paas_admin_id')

    #if (admin_id not in admin_id_list) and (admin_password_file):
     #   return redirect('/')

    if request.method == 'POST':
        pass

    a_votes = int(c.kv.get(option_a)[1]["Value"])
    b_votes = int(c.kv.get(option_b)[1]["Value"])
    c_votes = int(c.kv.get(option_c)[1]["Value"])

    return render_template('admin.html',
        option_a=option_a,
        option_b=option_b,
        option_c=option_c,
        a_votes=a_votes,
        b_votes=b_votes,
        c_votes=c_votes,
        hostname=hostname)
github Jinmo / ctfs / 2017 / codegatequals / pngparser_app.py View on Github external
@app.route('/fileupload', methods=['POST'])
def fileupload():
    file = request.files['upload_file']
    if not file:
        return render_template('result.html', result="Invalid Input ~.~")

    png_data = file.read()
    png_img = base64.b64encode(png_data)
    out = parser_run(png_data)

    return render_template('result.html', png_img=png_img, result=out)
github indico / indico / indico / web / errors.py View on Github external
def render_error(exc, title, message, code, standalone=False):
    _save_error(exc, title, message)
    if _need_json_response():
        return _jsonify_error(exc, title, message, code)
    elif standalone:
        return render_template('standalone_error.html', error_message=title, error_description=message), code
    else:
        try:
            return WPError(title, message).getHTML(), code
        except OperationalError:
            # If the error was caused while connecting the database,
            # rendering the error page fails since e.g. the header/footer
            # templates access the database or calls hooks doing so.
            # In this case we simply fall-back to the standalone error
            # page which does not show the indico UI around the error
            # message but doesn't require any kind of DB connection.
            return render_error(exc, title, message, code, standalone=True)
github jokull / calepin / calepin / app.py View on Github external
def page_not_found(e):
    return render_template('404.html'), 404
github LMFDB / lmfdb / lmfdb / number_field_galois_groups / main.py View on Github external
def render_nfgg_set_webpage(degree, size):
    the_nfggs = NumberFieldGaloisGroup.find({"Degree": int(degree), "Size": int(size)})

    # nfgg_logger.info("Found %s"%(the_nfggs._data))

    bread = get_bread([(str("Degree %s, size %s" % (degree, size)), ' ')])
    title = "Number field Galois groups of degree $%s$ and size $%s$" % (degree, size)

    return render_template("nfgg-set-show.html", credit=tim_credit, support=support_credit, title=title, bread=bread, info=the_nfggs)
github pawamoy / shell-history / src / shellhistory / app.py View on Github external
def monthly_view():
    return render_template("monthly.html")
github Floens / uchan / uchan / view / mod / mod_page.py View on Github external
if request.method == 'POST' and add_page_form.validate():
        title = add_page_form.title.data
        link_name = add_page_form.link.data
        page_type = add_page_form.type.data

        page = PageModel.from_title_link_type(title, link_name, page_type)

        try:
            page = page_service.create_page(page)
            flash('Page created')
            return redirect(url_for('.mod_page', page=page))
        except ArgumentError as e:
            add_page_messages.append(e.message)

    return render_template('mod_pages.html', pages=pages, page_types=page_types, add_page_form=add_page_form,
                           add_page_messages=add_page_messages)
github globocom / secDevLabs / owasp-top10-2017-apps / a10 / games-irados / app / routes.py View on Github external
if psw1 == psw2:
            psw = Password(psw1)
            hashed_psw = psw.get_hashed_password()
            message, success = database.insert_user(username, hashed_psw)
            if success == 1:
                flash("Novo usuario adicionado!", "primary")
                return redirect('/login')
            else:
                flash(message, "danger")
                return redirect('/register')

        flash("Passwords must be the same!", "danger")
        return redirect('/register')
    else:
        return render_template('register.html')
github projectshift / shift-boiler / boiler / user / user_service.py View on Github external
def send_password_change_message(self, user, base_url):
        """ Send password change message"""
        subject = 'Change your password here'
        if 'password_change' in self.email_subjects.keys():
            subject = self.email_subjects['password_change']

        sender = current_app.config['MAIL_DEFAULT_SENDER']
        recipient = user.email
        link = '{url}/{link}/'.format(
            url=base_url.rstrip('/'),
            link=user.password_link
        )
        data = dict(link=link)
        html = render_template('user/mail/password-change.html', **data)
        txt = render_template('user/mail/password-change.txt', **data)

        mail.send(Message(
            subject=subject,
            recipients=[recipient],
            body=txt,
            html=html,
            sender=sender
        ))