Serving Content

Expansive includes a built-in web server based on the high-performance Appweb embedded web server. This is a fast, secure, embedded web server that is ideal for testing your site before production deployment.

To serve your web site, run expansive serve.

$ expansive serve [Listen] [Render] Initial render ... [Watching] for changes every 1 sec ...

When serving, expansive will first render the site and then serve the requests from the rendered pages under the dist directory. It will then listen on port 4000 by default, for browser requests. So open your browser and go to http://localhost:4000 to see your site.

You can also omit the serve command and simply invoke expansive which is a convenient short-form.

$ expansive

Listening Address

The listening address can be set on the command line via the --listen switch.

$ expansive --listen 5000

This will listen on port 5000 on all interfaces. Use --listen to listen on local interfaces only.

You can also add a control.listen property to the package.json file.

{ control: { listen: '' } }

External Servers

You can configure Expansive to run an external server by defining the control.server property. This server will be automatically started when Expansive is serving pages. If the server dies or exits prematurely, Expansive will automatically restart.

For example:

control: { server: 'esp --trace stdout:4' }

If content is modified, Expansive will render the content and restart the server.

Watching for Changes

If content changes, expansive will transparently render the site as required. If a single page is modified, that page alone will be re-rendered. If a layout page or partial page is modified, the entire site will be rendered.

If you wish to disable watching for modified content while serving, run with the --nowatch option.

$ expansive --nowatch

If your site is already rendered before serving via a prior expansive render, you can disable the initial render for a faster startup via expansive --norender.

$ expansive --norender

© Embedthis Software. All rights reserved.