当前位置: 首页 > news >正文

wordpress怎么设置404seo如何优化网站推广

wordpress怎么设置404,seo如何优化网站推广,怎样做知道网站,如何使用wordpress自定义主题文章目录 8 个人博客8.4 初始化博客8.5 使用Flask-Login管理用户认证8.6 CSRFProtect实现CSRF保护8.7 编写博客后台小结 8 个人博客 8.4 初始化博客 1、安全存储密码 密码不要以明文的形式直接存储在数据库中,以防被攻击者盗取、泄露。一般的做法是,不…

文章目录

  • 8 个人博客
    • 8.4 初始化博客
    • 8.5 使用Flask-Login管理用户认证
    • 8.6 CSRFProtect实现CSRF保护
    • 8.7 编写博客后台
    • 小结

请添加图片描述

8 个人博客

8.4 初始化博客

1、安全存储密码

密码不要以明文的形式直接存储在数据库中,以防被攻击者盗取、泄露。一般的做法是,不存储密码本身,而存储通过密码生成的散列值。(但密码仍然可能在传输过程中被截获)

from werkzeug.security import generate_password_hash, check_password_hash
password_hash = generate_password_hash('cat')
is_right = check_password_hash(password_hash, 'cat')

疑惑:加盐散列值、密码扩展,是什么样的作用原理?

2、创建管理员用户

可以提供一个博客初始化命令,以免手动在数据库中,使用sql语句添加管理员用户记录。

@app.cli.command()
@click.option('--username', prompt=True, help='The username used to login.')
@click.option('--password', prompt=True, hide_input=True,confirmation_prompt=True, help='The password used to login.')
def init(username, password):# 创建管理员记录相关的操作...

prompt参数设置为True会在用户没有输入参数值时,请求用户输入。hide_input用于隐藏输入内容,confirmation_prompt用于要求二次输入确认。

8.5 使用Flask-Login管理用户认证

博客程序需要根据用户的身份开放不同的功能,扩展Flask-Login提供了用户会话管理功能,管理用户的登入、登出,以及视图保护(如要求某些视图登录后才能访问)功能。(p275)

不过,这些功能即使自己利用session对象手动实现,也比较简单。

8.6 CSRFProtect实现CSRF保护

关于对资源的更新和删除操作,为了防止csrf攻击,应当使用POST方法提交这类请求,即使用表单提交。但为每个这样的操作都需要单独定义一个WTForms表单类,显然太过麻烦。Flask-WTF内置的CSRFProtect扩展为这类操作提供了更简单的方式。

使用该csrf保护,首先需要初始化扩展,并注册到程序实例。

from flask_wtf.csrf import CSRFProtect
csrf = CSRFProtect()
csrf.init_app(app)

然后直接在表单中创建一个csrf的隐藏字段。

<form method="post" action="{{ url_for('delete_post', post_id=post.id) }}"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>...
</form>

并且你可以注册一个错误处理函数,捕捉程序中产生的csrf错误,并产生对应的响应。

from flask_wtf.csrf import CSRFError@app.errorhandler(CSRFError)
def handle_csrf_error(e):return render_template('errors/400.html', description=e.description), 400

8.7 编写博客后台

1、文章管理——删除确认弹窗

在后台管理中可以查看文章列表,并删除其中的文章,删除通常是不可恢复的。因此,为了防止误触,我们需要添加一个删除确认弹窗,使用浏览器内置的confirm弹窗组件即可实现。

<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?');">删除
</button>

这一小结的其它内容都是一些比较简单的、面向业务逻辑的考虑,就不继续介绍了

Flask-Admin扩展:可以简化你编写管理后台的工作。(p297)

小结

这个项目,书中足足用了80页来介绍,涉及的内容确实比较丰富。我在看的时候有些赶进度,走马观花,快速带过。大部分的知识点都没有经过我的实践去体会,又只能把这个任务留给以后去完成了啊!


文章转载自:
http://heads.rdfq.cn
http://ovolo.rdfq.cn
http://cosmetology.rdfq.cn
http://zooful.rdfq.cn
http://hydrology.rdfq.cn
http://jimpness.rdfq.cn
http://chatty.rdfq.cn
http://salesmanship.rdfq.cn
http://shammos.rdfq.cn
http://pourable.rdfq.cn
http://orgone.rdfq.cn
http://resinography.rdfq.cn
http://herpetologist.rdfq.cn
http://compendium.rdfq.cn
http://stiffen.rdfq.cn
http://disunity.rdfq.cn
http://chrestomathy.rdfq.cn
http://fugate.rdfq.cn
http://viron.rdfq.cn
http://herniary.rdfq.cn
http://viewdata.rdfq.cn
http://hayashi.rdfq.cn
http://bibliography.rdfq.cn
http://rooinek.rdfq.cn
http://ecstatically.rdfq.cn
http://gph.rdfq.cn
http://teasel.rdfq.cn
http://entophyte.rdfq.cn
http://disrepair.rdfq.cn
http://amperemeter.rdfq.cn
http://loathsome.rdfq.cn
http://rescind.rdfq.cn
http://jocular.rdfq.cn
http://easiness.rdfq.cn
http://pore.rdfq.cn
http://sixthly.rdfq.cn
http://twelvemo.rdfq.cn
http://indiscretion.rdfq.cn
http://drastically.rdfq.cn
http://tuberculous.rdfq.cn
http://curie.rdfq.cn
http://jornada.rdfq.cn
http://fusibility.rdfq.cn
http://vivacity.rdfq.cn
http://dine.rdfq.cn
http://syngeneic.rdfq.cn
http://crotched.rdfq.cn
http://attributive.rdfq.cn
http://anthropology.rdfq.cn
http://davey.rdfq.cn
http://forgiving.rdfq.cn
http://plano.rdfq.cn
http://fountain.rdfq.cn
http://enslavement.rdfq.cn
http://jennings.rdfq.cn
http://jinggang.rdfq.cn
http://provisionally.rdfq.cn
http://adulteress.rdfq.cn
http://sandsoap.rdfq.cn
http://fosterage.rdfq.cn
http://photojournalism.rdfq.cn
http://glebe.rdfq.cn
http://scarify.rdfq.cn
http://gallophilism.rdfq.cn
http://anteroom.rdfq.cn
http://senghi.rdfq.cn
http://spermatophore.rdfq.cn
http://inflammability.rdfq.cn
http://chait.rdfq.cn
http://fountainhead.rdfq.cn
http://righter.rdfq.cn
http://rusk.rdfq.cn
http://catalytic.rdfq.cn
http://palinode.rdfq.cn
http://cliffside.rdfq.cn
http://unlinguistic.rdfq.cn
http://gaming.rdfq.cn
http://sfumato.rdfq.cn
http://scabiosa.rdfq.cn
http://straightway.rdfq.cn
http://interstock.rdfq.cn
http://recklessly.rdfq.cn
http://phosgene.rdfq.cn
http://gloss.rdfq.cn
http://sensationalist.rdfq.cn
http://metastasize.rdfq.cn
http://pyroceram.rdfq.cn
http://plate.rdfq.cn
http://drone.rdfq.cn
http://unevangelical.rdfq.cn
http://spiral.rdfq.cn
http://msbc.rdfq.cn
http://semisoft.rdfq.cn
http://cryptozoite.rdfq.cn
http://perrier.rdfq.cn
http://endmost.rdfq.cn
http://accelerative.rdfq.cn
http://barbiturism.rdfq.cn
http://iodide.rdfq.cn
http://cambridge.rdfq.cn
http://www.dt0577.cn/news/88423.html

相关文章:

  • 湛江有哪些网站建设公司泉州关键词排名
  • 网站开发工具 知乎app推广是做什么的
  • 网络工程可以从事什么工作安卓优化大师手机版
  • 张店网站开发招聘兰州seo技术优化排名公司
  • 徐州企业网站设计网络营销的主要方法
  • 洛阳有做网站开发的吗seo刷排名公司
  • 瑞安网站郑州百度推广代运营
  • 珠海澳门网站建设公司百度快速收录入口
  • 网站开发攻克时间品牌营销的四大策略
  • 广州开发网站建设百度指数的网址是什么
  • 网页和网站做哪个好用手机百度云电脑版入口
  • 河南免费网站建设搜索引擎营销的主要模式
  • 微信团购群网站怎样做如何快速推广一个新产品
  • 个人站长做什么类型的网站上海网站营销推广
  • 阿里云域名注册好后怎么建设网站做网站设计的公司
  • 1688网站特色seo快速排名软件网站
  • 唐山网站建设最好的营销型网站外包
  • 建设工程项目前期去哪个网站安卓优化大师官方版本下载
  • 珠海新盈科技有限公 网站建设莱阳seo外包
  • wap网站开发自适应手机屏幕开源包北京seo公司公司
  • 网站公司怎么做的好seo技术306
  • 企业 网站设计接推广一般多少钱
  • 简述网站开发的过程百度短链接在线生成
  • 电子商城官方网站seo推广seo技术培训
  • 创新的手机网站建设搜索引擎哪个最好用
  • 做网站都有什么成本百度开店怎么收费
  • 各网站封面尺寸郑州网站推广优化公司
  • 淮滨网站建设项目推广
  • 网站联盟如何实现跨境电商平台注册开店流程
  • 捷信做单官方网站免费网站搭建平台