Skip to content

Commit

Permalink
improve: 更に環境変数を使うように
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosugamea committed Nov 22, 2020
1 parent 81945d8 commit 844bc44
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ AUTH_LINE_NOTIFY_REDIRECT_CONNECT='https://example.com/connect/line_notify'
TOYMONEY_ENDPOINT='http://localhost:7070'
TOYMONEY_TOKEN=''
TOYMONEY_PASSWORD_HEAD='***REMOVED***'
API_TELEGRAM_TOKEN=''
API_IMGUR_TOKEN=''
API_SAUCENAO_TOKEN=''
API_ONESIGNAL_APPID=''
API_ONESIGNAL_TOKEN=''
API_NICONICO_MAIL=''
API_NICONICO_PASS=''
API_NICONICO_TOKEN=''
API_NICONICO_FILE=''
API_PIXIV_FILE=''
API_TWITTER_CONSUMER_KEY=''
API_TWITTER_CONSUMER_SECRET=''
API_TWITTER_AUTH_TOKEN=''
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ venv.bak/
blueprints/*.json
static/illusts/
db_data
api_data
api_data
auth/
11 changes: 9 additions & 2 deletions api/blueprints/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
auth, limiter, handleApiPermission, record
)
from ..scraper_lib.onesignal_client import OneSignalWrappedClient
from os import environ
from dotenv import load_dotenv

# .env読み込み
load_dotenv(verbose=True, override=True)

notify_api = Blueprint('notify_api', __name__)
ONESIGNAL_APPID = environ.get('API_ONESIGNAL_APPID')
ONESIGNAL_TOKEN = environ.get('API_ONESIGNAL_TOKEN')


@notify_api.route('/setting/line', methods=["POST"], strict_slashes=False)
Expand Down Expand Up @@ -123,8 +130,8 @@ def addNotify():
if userOneSignalID:
userOneSignalID = userOneSignalID.split(",")
cl = OneSignalWrappedClient(
current_app.config['onesignalAppId'],
current_app.config['onesignalToken']
ONESIGNAL_APPID,
ONESIGNAL_TOKEN
)
cl.sendNotify(
userOneSignalID,
Expand Down
6 changes: 1 addition & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ def createApp():
app.config['JSON_AS_ASCII'] = False
app.config['JSON_SORT_KEYS'] = False
app.config['MAX_CONTENT_LENGTH'] = 20 * 1024 * 1024
app.config['ILLUST_FOLDER'] = 'static/illusts'
app.config['TEMP_FOLDER'] = 'static/temp'
app.config['onesignalAppId'] = environ.get('API_ONESIGNAL_APPID')
app.config['onesignalToken'] = environ.get('API_ONESIGNAL_TOKEN')
# 各ページルールを登録
app.add_url_rule('/', 'index', app_index, strict_slashes=False)
app.add_url_rule('/favicon.ico', 'favicon.ico', app_favicon)
Expand Down Expand Up @@ -88,4 +84,4 @@ def createApp():

if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0')
app.run(host='0.0.0.0', port=5000)

0 comments on commit 844bc44

Please sign in to comment.