-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
40 lines (31 loc) · 1.08 KB
/
run.py
File metadata and controls
40 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from app import create_app
from app.models import db
from config import Config
from flask import Flask, redirect, url_for
app = create_app(Config)
# ルートディレクトリでのデプロイ - サブパス設定は不要
@app.cli.command('create-db')
def create_db():
"""データベーステーブルを作成"""
with app.app_context():
db.create_all()
print('データベーステーブルを作成しました')
@app.cli.command('create-super-user')
def create_super_user():
"""スーパーユーザーを作成"""
from app.models.user import SuperUser
import getpass
email = input('メールアドレス: ')
username = input('ユーザー名: ')
password = getpass.getpass('パスワード: ')
super_user = SuperUser(
email=email,
username=username
)
super_user.set_password(password)
with app.app_context():
db.session.add(super_user)
db.session.commit()
print(f'スーパーユーザー {username} を作成しました')
if __name__ == '__main__':
app.run(debug=True)