python template.render_Python flask.render_template方法代码示例

本文详细介绍了 Python Flask 框架中 `render_template` 函数的使用方法,通过多个代码示例展示了如何在 Flask 应用中渲染 HTML 模板。内容包括不同场景的应用,如首页、用户主页、课程评价、视频流等,适用于初学者和进阶开发者。
摘要由CSDN通过智能技术生成

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

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

示例1: index

​点赞 6

# 需要导入模块: 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,

示例2: show_review

​点赞 6

# 需要导入模块: 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,

示例3: main

​点赞 6

# 需要导入模块: 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,

示例4: make_web

​点赞 6

# 需要导入模块: import flask [as 别名]

# 或者: from flask import render_template [as 别名]

def make_web(queue):

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值