赞
踩
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
<span id="prompt" style="display: flex; justify-content: center; align-items: center;">
Please sign in with Google:
</span>
<br/>
<div id="login\_zone" style="display: flex; justify-content: center; align-items: center;">
<div id="g\_id\_onload"
data-client_id=“client_id”
data-context=“signin”
data-ux_mode=“popup”
data-auto_prompt=“false”
data-callback=“onLoginCallback”>
<div class="g\_id\_signin"
data-type=“standard”
data-shape=“pill”
data-theme=“filled_blue”
data-text=“signin_with”
data-size=“large”
data-logo_alignment=“left”>
<span id="user\_info" style="display: flex; justify-content: center; white-space: pre-line;"></span>
<script>
function onLoginCallback(response) {
var credential = response.credential,
sub_credential = credential.split(“.”)[1].replace(/-/g, “+”).replace(/_/g, “/”),
profile = JSON.parse(decodeURIComponent(escape(window.atob(sub_credential)))),
target = document.getElementById(“user_info”),
html = “”;
html += "ID: " + profile.sub + “\n”;
html += "Name: " + profile.name + “\n”;
html += "Email: " + profile.email + “\n”;
target.innerHTML = html;
document.getElementById(“prompt”).style.display = “none”;
document.getElementById(“login_zone”).style.display = “none”;
}
3.编写Web示例app.py: 应用以debug模式运行在本地的7777端口,端口号与Google中配置的一致
from flask import Flask, render_template
app = Flask(name)
@app.route(“/”, methods=[“GET”])
def index():
return render_template(“index.html”)
if name == “__main__”:
app.run(host=“localhost”, port=7777, debug=True)
4.运行Web示例应用,即可使用Google账号登录网站 ![](https://img-blog.csdnimg.cn/direct/39060e9e9fc3415e84cc0717ca33c8ff.png#pic_center) ![](https://img-blog.csdnimg.cn/direct/dc24b34b4f4247a1aaac353e3106e3d2.png#pic_center) ![](https://img-blog.csdnimg.cn/direct/db5df7cf123541bcab36c1125efedaa5.png#pic_center) 注: 生产环境中需要自行实现代码逻辑,使用Google的credential来认证用户并管理用户会话的生命周期。 --- 至此教程结束。 有错误或者改进的地方请各位积极指出! ![img](https://img-blog.csdnimg.cn/img_convert/dbee8d720088cb20a81ca6291c56f301.png) ![img](https://img-blog.csdnimg.cn/img_convert/6f8d22166dd9e0cb9763a9b64fe17f40.png) ![img](https://img-blog.csdnimg.cn/img_convert/425a0c2be5fe67014d9201ef7bb89f04.png) **既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Go语言开发知识点,真正体系化!** **由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新** **[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618658159)** 由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新** **[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618658159)**
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。