Give `create_app` a dictionary, not a file location

l10n
n9k 2ヶ月前
コミット 617a687145
  1. 6
      anonstream/__init__.py
  2. 5
      anonstream/__main__.py
  3. 5
      asgi.py

@ -3,7 +3,6 @@
from collections import OrderedDict
import toml
from quart_compress import Compress
from anonstream.config import update_flask_from_toml
@ -12,15 +11,12 @@ from anonstream.quart import Quart
compress = Compress()
def create_app(config_file):
def create_app(toml_config):
app = Quart('anonstream')
app.jinja_options['trim_blocks'] = True
app.jinja_options['lstrip_blocks'] = True
with open(config_file) as fp:
toml_config = toml.load(fp)
auth_password = update_flask_from_toml(toml_config, app.config)
print('Broadcaster username:', app.config['AUTH_USERNAME'])
print('Broadcaster password:', auth_password)

@ -1,6 +1,7 @@
import argparse
import os
import toml
import uvicorn
from anonstream import create_app
@ -44,5 +45,7 @@ parser.add_argument(
)
args = parser.parse_args()
app = create_app(args.config)
with open(args.config) as fp:
config = toml.load(fp)
app = create_app(config)
uvicorn.run(app, port=args.port)

@ -12,12 +12,15 @@ if __name__ == '__main__':
exit(1)
import os
import toml
import anonstream
config = os.environ.get(
config_file = os.environ.get(
'ANONSTREAM_CONFIG',
os.path.join(os.path.dirname(__file__), 'config.toml'),
)
def create_app():
with open(config_file) as fp:
config = toml.load(fp)
return anonstream.create_app(config)

読み込み中…
キャンセル
保存