Default the host configuration to 0.0.0.0
This commit is contained in:
parent
782e0b0ad6
commit
790e0a1ce5
2 changed files with 5 additions and 8 deletions
|
|
@ -6,12 +6,12 @@ from .logging import Logging
|
|||
from .email import Email
|
||||
from .auth import Auth
|
||||
from .database import Database
|
||||
from .parse import assert_key_of_type, parse_nested_config
|
||||
from .parse import parse_nested_config
|
||||
|
||||
|
||||
@dataclass
|
||||
class Config:
|
||||
host: str | None
|
||||
host: str
|
||||
port: int | None
|
||||
logging: Logging
|
||||
email: Email
|
||||
|
|
@ -20,17 +20,14 @@ class Config:
|
|||
|
||||
@classmethod
|
||||
def from_dict(cls, config: dict[str, Any]) -> 'Config':
|
||||
assert_key_of_type(config, 'host', str)
|
||||
assert_key_of_type(config, 'port', int)
|
||||
|
||||
log_config = parse_nested_config(config, 'logging', Logging.from_dict)
|
||||
email_config = parse_nested_config(config, 'email', Email.from_dict)
|
||||
db_config = parse_nested_config(config, 'database', Database.from_dict)
|
||||
auth_config = parse_nested_config(config, 'auth', Auth.from_dict)
|
||||
|
||||
return Config(
|
||||
host=config['host'],
|
||||
port=config['port'],
|
||||
host=config.get('host', '0.0.0.0'),
|
||||
port=config.get('port'),
|
||||
email=email_config,
|
||||
logging=log_config,
|
||||
database=db_config,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ def main():
|
|||
config = parse_config(args.config)
|
||||
app = create_app('Cereal', config)
|
||||
logger.info(str(config))
|
||||
serve(app, host='0.0.0.0' if config.host is None else config.host, port=config.port)
|
||||
serve(app, host=config.host, port=config.port)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue