13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Flask-AppBuilderを使用し、認証、ユーザ管理、多言語システムを簡単に作成する

Last updated at Posted at 2017-05-08

試した環境

OSX, Python2.7.13, virtualenv

Flask-AppBuilder (F.A.B or FAB)

インストール詳細

% virtualenv env 

% source env/bin/activate

% pip install flask-appbuilder

% fabmanager create-app testapp

% fabmanager create-app
Your new app name: testapp
Your engine type, SQLAlchemy or MongoEngine [SQLAlchemy]: 
Downloaded the skeleton app, good coding!

% cd testapp

# adminユーザを作る
% fabmanager create-admin 
Username [admin]:
User first name [admin]:
User last name [user]:
Email [admin@fab.org]:
Password:
Repeat for confirmation:
...
Recognized Database Authentications.
2017-05-08 22:39:16,699:INFO:flask_appbuilder.security.sqla.manager:Added user admin
Admin User admin created.

# 日本語を有効にする
% vi config.py
#coding:utf8 # <-- ファイルの先頭に入れる

# 以下を探し、jaを追加または入れ替える
LANGUAGES = {
    'en': {'flag': 'gb', 'name': 'English'},
    'ja': {'flag': 'jp', 'name': u'日本語'},
}

% fabmanager run
...
2017-05-08 22:43:34,014:WARNING:werkzeug: * Debugger is active!
2017-05-08 22:43:34,030:INFO:werkzeug: * Debugger PIN: ....

ブラウザーでhttp://localhost:8080/にアクセス

  1. トップページ
    a1.png

  2. ログイン画面
    a2.png

  3. ログイン後
    a3.png

  4. 日本語に変えてみる
    a4.png

  5. ユーザの一覧ページ
    a5.png

  6. ユーザ情報編集ページ
    a6.png

  7. セキュリティ的なcsrfとかもデフォルトで対応
    a7.png

airbnb製のsupersetはFlask-AppBuilderで作成されています。
https://github.com/airbnb/superset

ちなみにmasterのCIと管理画面の一部壊れていたのでPR投げました
https://github.com/dpgaspar/Flask-AppBuilder/commit/ad0c16e960d2923184cf15b5788338ad66289011
https://github.com/dpgaspar/Flask-AppBuilder/commit/d469462425a4756b4b9cf2a0b2313ee7f65769e5

13
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?