views.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:lighthouse 作者: dstl 项目源码 文件源码
def get_context_data(self, **kwargs):
        context = super(StaticPageViewBase, self).get_context_data(**kwargs)
        if not self.slug:
            self.slug = kwargs['slug']
        filename = self.get_markdown_filename()
        try:
            input_file = codecs.open(
                filename,
                mode="r",
                encoding="utf-8"
            )
        except FileNotFoundError:
            raise Http404
        text = input_file.read()
        html = markdown.markdown(text)
        context['html_content'] = html
        return context
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号