当前位置:网站首页>About integrating superset into your own project
About integrating superset into your own project
2022-07-31 05:38:00 【Silver fish】
下载&安装
方式一:pip install apache-superset
方式二:https://github.com/apache/superset.git
搭建虚拟环境(可选)
1.安装anaconda (https://www.anaconda.com/products/individual#Downloads)
2.anaconda下run一个python环境,(推荐python3.8)
运行
1.superset db upgrade #初始化数据库
2.superset fab create-admin #初始化用户
3.superset init # 初始化
4.superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger # 启动
This process may have many pit,I met a few listed below and the solution:
1.Python-geohash、sasl包有问题:
下载文件安装:https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-geohash
2.markupsafe模块有问题:
安装201版本:pip install markupsafe==2.0.1
3.建议python-v >= 3.8
4.a "wsgi.py" or "app.py" module was not found in the current directory.
CD到app.pyUnder the directory to performsuperset run命令
5.pip install Pillow
未安装Piollow可能会导致run不起来
6.error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio":
下载安装:https://visualstudio.microsoft.com/downloads/
superset的集成
本文用的方式是Button点击跳URLTo the deployment ofsuperset上,The following system and permissions to access account processing.
superset采用flask-appbuilder做身份验证,About how to access the user,The official documentation for details:Security — Flask AppBuilder
本文的思路是:拦截/loginThe request to your own project,Make the function of login and verify.At the same time to the alogin的CallBack URLLet their success in landing back tone system,在回调时把UserWrites the current system ofSession中去.Logout也是同样的道理.都是使用CallBack URL来做的.代码如下:
# config.py
from flask_appbuilder.security.manager import AUTH_REMOTE_USER
from my_security_manager import MySecurityManager
AUTH_TYPE = AUTH_REMOTE_USER # 设置模式
CUSTOM_SECURITY_MANAGER = MySecurityManager # 引入自己写的Security
AUTH_USER_REGISTRATION = True # 允许用户注册
AUTH_USER_REGISTRATION_ROLE = "Gamma" # Set the default add user role
# 与seperset文件夹同级目录下创建 my_security_manager.py
LOGIN_SERVER_URL = 'http://10.113.72.88:5000/login' # Access to the system login interface
CHECK_SERVER_URL = 'http://10.113.72.88:5000/check' # Access to the system oftoken检查接口
LOGINOUT_SERVER_URL = 'http://10.113.72.88:5000/logout' # System access to the appropriate interface
class MyAuthRemoteUserView(AuthRemoteUserView):
# 需继承config.py中AUTH_TYPEThe value corresponding to the parent class
login_template = 'appbuilder/general/security/login_my.html'
title = "My Login"
@expose('/login/', methods=['GET', 'POST'])
def login(self):
token = request.args.get('token')
if not token:
token = request.cookies.get('access_token')
if not token:
return redirect(LOGIN_SERVER_URL)
manager = self.appbuilder.sm
# According to modify your system parameters
result = requests.get(CHECK_SERVER_URL + '?token=' + token)
# According to modify your system validation condition
if result.status_code != 200:
return redirect(LOGIN_SERVER_URL)
# Where access is,只验证token是否有效,All users to entersupersetSee the same page
# 同一个superset账号(admin)
username = "admin"
user = manager.find_user(username=username)
login_user(user, remember=False)
return redirect(self.appbuilder.get_url_for_index)
# Can also according to different login account insupersetGenerated in the different account,Different user interface is different.
# Equivalent to the corresponding access system account number insuperset中进行创建,同时修改login方法,In the custom login.
# if token is not None:
# jwt_payload = jwt.decode(token, 'secret', algorithms=['RS256'])
# user_name = jwt_payload.get("user_name")
# user = self.appbuilder.sm.find_user(username=user_name)
# if not user:
# role_admin = self.appbuilder.sm.find_role('Admin')
# user = self.appbuilder.sm.add_user(user_name, user_name, 'aimind', user_name + "@aimind.com", role_admin, password="aimind" + user_name)
# if user:
# login_user(user, remember=False)
# redirect_url = request.args.get('redirect')
# if not redirect_url:
# redirect_url = self.appbuilder.get_url_for_index
# return redirect(redirect_url)
# else:
# return super(AuthRemoteUserView, self).login()
class MySecurityManager(MyAuthRemoteUserView):
authremoteuserview = MyAuthRemoteUserView
边栏推荐
- leetcode-每日一题1252. 奇数值单元格的数目(模拟优化)
- vulhub靶场学习日记hackme2
- Flask-based three-party login process
- Three-party login using wallet Metamask based on web3.0
- C语言实验三 选择结构程序设计
- 【C语言趣味小游戏——猜数字】
- Redis Advanced - Cache Issues: Consistency, Penetration, Penetration, Avalanche, Pollution, etc.
- Flink sink ES 写入 ES(带密码)
- 剑指offer基础版 ----- 第28天
- mysql 的简单运用命令
猜你喜欢

账号或密码多次输入错误,进行账号封禁

再见了繁琐的Excel,掌握数据分析处理技术就靠它了

Redis Advanced - Cache Issues: Consistency, Penetration, Penetration, Avalanche, Pollution, etc.

With MVC, why DDD?

The process and specific code of sending SMS verification code using flask framework

剑指offer基础版 --- 第22天

gin框架学习-JWT认证

【LeetCode-SQL每日一练】——2. 第二高的薪水

vulhub靶场学习日记hackme1

数据库上机实验7 数据库设计
随机推荐
Swordsman Offer Special Assault Edition --- Day 3
leetcode-2321. 拼接数组的最大分数(差分+枚举)
vulhub靶场学习日记xxe-lab
Redis管道技术/分区
The interviewer asked me TCP three handshake and four wave, I really
10 【高度塌陷与BFC】
[MQ I can speak for an hour]
基于flask的三方登陆的流程
C语言如何分辨大小端
gin框架学习-Casbin进阶之策略管理API使用方法
Interviewer, don't ask me to shake hands three times and wave four times again
Kubernetes certificate validity period modification
剑指offer基础版 ---- 第29天
Element concatenation operations in numpy and pytorch: stack, concatenat, cat
Memcached :安装
Data set partitioning and cross-validation
leetcode-438. 找到字符串中所有字母异位词(滑动窗口)
剑指offer基础版 ---- 第26天
uni-app进阶之创建组件/原生渲染【day9】
字符串的新增方法