Moya Static

Moya Static serves files from any filesystem in the project, and can generate index pages.


Moya Static is built in to Moya and may be imported via its Python path as follows:

<import py="moya.libs.static"/>

The above line should be in your <server> declaration.

You can install the library with the following:

<install name="media" lib="moya.static" mount="/static/"/>


dirlist = <yes/no>

If set to yes then Moya Static will render index pages containing a directory listing. It is useful to have this enabled during development so you can see exactly what files are being served, but you may want to disable this on a production site.


Set this to one of the filesystems you would like to serve files from.


This should be a list of wildcards that should not be served. You might want to hide temporary / configuration files for example.

Here's how you would hide files with a filename that begin with a dot (hidden files in linux) and files ending with a tilde (~), which are often used as temporary files:

hide = .*

index = <INDEX FILES>

This setting applies to index pages only, i.e. URLs ending with a forward slash. If any of the specified files are present, then Moya will serve them as HTML. If used, this setting is typically set to the following, to emulate the classic behavior of web servers:

index = index.htm

Moya Serve Command

The moya serve command uses Moya Static to serve the contents of a directory (without the need to create a project). For instance, the following command will serve the files in the current directory (and subdirectories):

$ moya serve .

If you run this, you can visit to view the directory contents.

You may set the host and port for the web server from the command line. The following will display the details in the terminal:

$ moya serve -h
NOTE This comand is useful to serve files in a pinch, but isn't intended for production.