async def _serve(app: App): if not path.isdir(app.configuration.www_directory_path): raise CommandValueError('Web root directory "%s" does not exist.' % app.configuration.www_directory_path) async with serve.AppServer(app): while True: time.sleep(999)
async def _serve(app: App): async with app: if not path.isdir(app.configuration.www_directory_path): raise UserFacingError('Web root directory "%s" does not exist.' % app.configuration.www_directory_path) async with serve.AppServer(app): while True: await asyncio.sleep(999)
def __init__(self, app: App, *args, **kwargs): super().__init__(*args, **kwargs) self._server = serve.AppServer(app) if not path.isdir(app.configuration.www_directory_path): self.close() raise ConfigurationError( 'Web root directory "%s" does not exist.' % app.configuration.www_directory_path)
async def start(self) -> None: self._output_directory = TemporaryDirectory() output_directory_path = await self._output_directory.__aenter__() configuration = Configuration(output_directory_path, 'https://example.com') configuration.extensions.add(ExtensionConfiguration(Demo)) # Include all of the translations Betty ships with. configuration.locales.replace([ LocaleConfiguration('en-US', 'en'), LocaleConfiguration('nl-NL', 'nl'), LocaleConfiguration('fr-FR', 'fr'), LocaleConfiguration('uk', 'uk'), ]) self._app = App(configuration) self._server = None await self._app.activate() await load.load(self._app) await generate.generate(self._app) self._server = serve.AppServer(self._app) await self._server.start()
async def start(self) -> None: self._output_directory = TemporaryDirectory() configuration = Configuration(self._output_directory.name, 'https://example.com') configuration.extensions[Demo] = None # The Nginx extension allows content negotiation if Docker is also available. configuration.extensions[Nginx] = {} # Include all of the translations Betty ships with. locale_configurations = [ LocaleConfiguration('en-US', 'en'), LocaleConfiguration('nl-NL', 'nl'), LocaleConfiguration('fr-FR', 'fr'), LocaleConfiguration('uk', 'uk'), ] for locale_configuration in locale_configurations: configuration.locales[ locale_configuration.locale] = locale_configuration self._app = App(configuration) self._server = None await self._app.enter() await load.load(self._app) await generate.generate(self._app) self._server = serve.AppServer(self._app) await self._server.start()