作者:微信小助手
发布时间:2019-08-05T08:45:24
点击▲关注 “爪哇笔记” 给公众号标星置顶
更多精彩 第一时间直达
前言
通过 Python 爬取十万博文之后,最重要的是要让互联网用户访问到,那么如何做呢?
从后台框架、前端模板、数据库连接池、缓存、代理服务、限流等组件多个维度选型。
后台框架 SpringBoot2+、JPA
前端框架 Vue
模块框架 Thymeleaf
数据库连接池 HikariCP
缓存 Redis
限流 Guava
代理服务 Nginx
文章编辑 Markdown
我们可以通过以下方式访问:
https://blog.52itstyle.top/49.html
亦或是:
https://blog.52itstyle.top/49.shtml
当然,如果你愿意你也可以显示为:
https://blog.52itstyle.top/49.php
https://blog.52itstyle.top/49.asp
https://blog.52itstyle.top/49.jsp
只需要在后台配置对应的映射关系即可:
/**
* 博文
*/
@RequestMapping("{id}.html")
public String blog(@PathVariable("id") Long id, ModelMap model) {
Blog blog = blogService.getById(id);
model.addAttribute("blog",blog);
return "article";
}
由于数据库存储的是 markedown 格式的数据,前台我们通过 editormd 转为 html 代码显示,这里只展示部分代码:
<script type='text/javascript' src='js/jquery.min.js'></script>
<!--省略部分代码-->
<script type='text/javascript' src="editor/editormd.min.js"></script>
<!--省略部分代码-->
<div id="article">
<textarea th:text="${blog.content}" style="display:none;" placeholder="markdown语言">
</textarea>
</div>
<!--省略部分代码-->