当前位置: 首页>>代码示例>>Python>>正文


Python flask.render_template方法代码示例

本文整理汇总了Python中flask.render_template方法的典型用法代码示例。如果您正苦于以下问题:Python flask.render_template方法的具体用法?Python flask.render_template怎么用?Python flask.render_template使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask的用法示例。


在下文中一共展示了flask.render_template方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_web

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def make_web(queue):
    app = Flask(__name__)

    @app.route('/')
    def index():
        return render_template('index.html')

    def gen():
        while True:
            frame = queue.get()
            _, frame = cv2.imencode('.JPEG', frame)
            yield (b'--frame\r\n'
                   b'Content-Type: image/jpeg\r\n\r\n' + frame.tostring() + b'\r\n')

    @app.route('/video_feed')
    def video_feed():
        return Response(gen(),
                        mimetype='multipart/x-mixed-replace; boundary=frame')

    try:
        app.run(host='0.0.0.0', port=8889)
    except:
        print('unable to open port') 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:25,代码来源:rl_data.py

示例2: index

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def index():
    if not "last_format" in session:
        session["last_format"] = "svg"
        session.permanent = True

    try:
        variantDescription = str(dataHub.variant).replace("::", " ").replace("-", "–")
        return render_template('index.html',
            samples=list(dataHub.samples.keys()), 
            annotations=dataHub.annotationSets,
            results_table=dataHub.getCounts(),
            insertSizeDistributions=[sample.name for sample in dataHub if sample.insertSizePlot], 
            dotplots=dataHub.dotplots,
            variantDescription=variantDescription)
    except Exception as e:
        logging.error("ERROR:{}".format(e))
        raise 
开发者ID:svviz,项目名称:svviz,代码行数:19,代码来源:web.py

示例3: show_review

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def show_review(cotc_id: int):
    """查看某个教学班的评价"""
    cotc_id = int(cotc_id)

    review_info = CourseReview.get_review(cotc_id)
    avg_rate = review_info['avg_rate']
    reviews = review_info['reviews']

    cotc = COTeachingClass.get_doc(cotc_id)
    if not cotc:
        return render_template('common/error.html', message=MSG_404)

    if session.get(SESSION_CURRENT_USER, None) \
            and CourseReview.get_my_review(cotc_id=cotc_id, student_id=session[SESSION_CURRENT_USER].identifier):
        reviewed_by_me = True
    else:
        reviewed_by_me = False
    return render_template('course/review.html',
                           cotc=cotc,
                           count=review_info['count'],
                           avg_rate=avg_rate,
                           reviews=reviews,
                           user_is_taking=is_taking(cotc),
                           reviewed_by_me=reviewed_by_me) 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:26,代码来源:views.py

示例4: main

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def main():
    """用户主页"""
    try:
        is_student, student = entity_service.get_people_info(session[SESSION_CURRENT_USER].identifier)
        if not is_student:
            return "Teacher is not supported at the moment. Stay tuned!"
    except Exception as e:
        return handle_exception_with_error_page(e)

    pending_grant_reqs = user_service.get_pending_requests(session[SESSION_CURRENT_USER].identifier)
    pending_grant_names = []
    for req in pending_grant_reqs:
        pending_grant_names.append(entity_service.get_people_info(req.user_id)[1].name)

    return render_template('user/main.html',
                           name=session[SESSION_CURRENT_USER].name,
                           student_id_encoded=session[SESSION_CURRENT_USER].identifier_encoded,
                           last_semester=student.semesters[-1] if student.semesters else None,
                           privacy_level=user_service.get_privacy_level(session[SESSION_CURRENT_USER].identifier),
                           pending_grant_names=pending_grant_names) 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:22,代码来源:views.py

示例5: login_required

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def login_required(func):
    """
    a decorator for routes which is only available for logged-in users.
    """

    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        if not session.get(SESSION_CURRENT_USER, None):
            return render_template('common/error.html', message=MSG_NOT_LOGGED_IN, action="login")
        return func(*args, **kwargs)

    return wrapped 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:14,代码来源:web_helpers.py

示例6: home

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def home():
    return render_template('painthathd.html') 
开发者ID:pimoroni,项目名称:unicorn-hat-hd,代码行数:4,代码来源:paint.py

示例7: index

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def index():
    host = request.url_root
    return render_template("index.html", host=host) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:5,代码来源:app.py

示例8: get_classroom

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def get_classroom(url_rid, url_semester):
    """教室查询"""
    # decrypt identifier in URL
    try:
        _, room_id = decrypt(url_rid, resource_type='room')
    except ValueError:
        return render_template("common/error.html", message=MSG_INVALID_IDENTIFIER)
    # todo 支持没有学期的room
    # RPC to get classroom timetable
    try:
        room = entity_service.get_classroom_timetable(url_semester, room_id)
    except Exception as e:
        return handle_exception_with_error_page(e)

    with tracer.trace('process_rpc_result'):
        cards = defaultdict(list)
        for card in room.cards:
            day, time = lesson_string_to_tuple(card.lesson)
            cards[(day, time)].append(card)

    empty_5, empty_6, empty_sat, empty_sun = _empty_column_check(cards)

    available_semesters = semester_calculate(url_semester, room.semesters)

    return render_template('entity/room.html',
                           room=room,
                           cards=cards,
                           empty_sat=empty_sat,
                           empty_sun=empty_sun,
                           empty_6=empty_6,
                           empty_5=empty_5,
                           available_semesters=available_semesters,
                           current_semester=url_semester) 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:35,代码来源:views.py

示例9: get_card

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def get_card(url_cid: str, url_semester: str):
    """课程查询"""
    # decrypt identifier in URL
    try:
        _, card_id = decrypt(url_cid, resource_type='klass')
    except ValueError:
        return render_template("common/error.html", message=MSG_INVALID_IDENTIFIER)

    # RPC to get card
    try:
        card = entity_service.get_card(url_semester, card_id)
    except Exception as e:
        return handle_exception_with_error_page(e)

    day, time = lesson_string_to_tuple(card.lesson)

    # cotc_id = COTeachingClass.get_id_by_card(card)
    # course_review_doc = CourseReview.get_review(cotc_id)

    return render_template('entity/card.html',
                           card=card,
                           card_day=get_day_chinese(day),
                           card_time=get_time_chinese(time),
                           # cotc_id=cotc_id,
                           # cotc_rating=course_review_doc["avg_rate"],
                           cotc_id=0,
                           cotc_rating=0,
                           current_semester=url_semester
                           ) 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:31,代码来源:views.py

示例10: available_rooms

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def available_rooms():
    return render_template("entity/available_rooms.html") 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:4,代码来源:views.py

示例11: electives

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def electives():
    return render_template('course/electives.html') 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:4,代码来源:views.py

示例12: elective_assistant

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def elective_assistant():
    return render_template('course/elective_assistant.html') 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:4,代码来源:views.py

示例13: disallow_in_maintenance

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def disallow_in_maintenance(func):
    """
    a decorator for routes which should be unavailable in maintenance mode.
    """

    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        config = get_config()
        if config.MAINTENANCE:
            return render_template('maintenance.html')
        return func(*args, **kwargs)

    return wrapped 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:15,代码来源:web_helpers.py

示例14: _error_page

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def _error_page(message: str, sentry_capture: bool = False, log: str = None):
    """return a error page with a message. if sentry is available, tell user that they can report the problem."""
    sentry_param = {}
    if sentry_capture and plugin_available("sentry"):
        sentry.captureException()
        sentry_param.update({"event_id": g.sentry_event_id,
                             "public_dsn": sentry.client.get_public_dsn('https')
                             })
    if log:
        logger.info(log)
    return render_template('common/error.html', message=message, **sentry_param) 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:13,代码来源:web_helpers.py

示例15: check_permission

# 需要导入模块: import flask [as 别名]
# 或者: from flask import render_template [as 别名]
def check_permission(student: StudentTimetableResult) -> Tuple[bool, Optional[str]]:
    """
    检查当前登录的用户是否有权限访问此学生

    :param student: 被访问的学生
    :return: 第一个返回值为布尔类型,True 标识可以访问,False 表示没有权限访问。第二个返回值为没有权限访问时需要返回的模板
    """
    can, reason = user_service.has_access(student.student_id,
                                          session.get(SESSION_CURRENT_USER).identifier if session.get(SESSION_CURRENT_USER, None) else None)
    if reason == user_service.REASON_LOGIN_REQUIRED:
        return False, render_template('entity/studentBlocked.html',
                                      name=student.name,
                                      falculty=student.deputy,
                                      class_name=student.klass,
                                      level=1)
    if reason == user_service.REASON_PERMISSION_ADJUST_REQUIRED:
        return False, render_template('entity/studentBlocked.html',
                                      name=student.name,
                                      falculty=student.deputy,
                                      class_name=student.klass,
                                      level=3)
    if not can:
        return False, render_template('entity/studentBlocked.html',
                                      name=student.name,
                                      falculty=student.deputy,
                                      class_name=student.klass,
                                      level=2)

    return True, None 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:31,代码来源:web_helpers.py


注:本文中的flask.render_template方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。