Load a Static Resource Example | MuleSoft Documentation
# Load a Static Resource Example
The Anypoint Connector for HTTP (HTTP Connector) **Load static resource** operation enables you to load a static resource, such as your home page or a script. You can configure the operation by setting the path and file name of a resource to load, and optionally set the name of another file in the same directory as the resource to use in case of failure.
The following example illustrates how to configure the HTTP **Listener** source and the **Load static resource** operation to serve up static content for use with HTTP, using the request path to lookup the resource. To accomplish this example, you must create the Mule app, configure an HTTP global element, run, and test the app with curl commands.
The following screenshot shows the Anypoint Studio app flow for this example:
## Create the Mule Application
To create the Mule flow:
  1. In the **Mule Palette** view, select the HTTP **Listener** source and drag it onto the canvas. The source initiates the flow by listening for incoming HTTP message attributes.
  2. Set the **Path** field to `/trigger` to start the app from the web browser.
  3. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of the HTTP **Listener** in the app.
  4. On the **General** tab, configure the following fields:
     * **Host** : `All Interfaces [0.0.0.0] (default)`
     * **Port** : `8081`
  5. Drag a **Load static resource** operation to the right of the HTTP **Listener** source.
  6. Set the **Resource base path** field to `/Users/max/Sites/index.html`.
  7. Set the **Default file** field to the name of a backup file in the same directory as the resource, for example `index.html`. If you need to use a relative path to the Mule project, use the variable `${app.workDir}`. For example, `resourceBasePath="${app.workDir}/images/"`. In the event of a failure, the app loads the backup file.
  8. Save your Mule app.
  9. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**.
  10. In a browser window, type the URL `http://0.0.0.0:8081/trigger`. The contents of the resource appear in the browser.


## XML for Loading a Static Resource
Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule app:
```
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<core:flow name="Flow" >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config"/>
		<http:load-static-resource doc:name="Load static resource" resourceBasePath="/Users/max/Sites/index.html" attributes="attributes"/>
	</core:flow>
</mule>
```

## See Also
  * Introduction to Anypoint Connectors
  * MuleSoft Help Center