---
schema_version: "1"
id: d1461d03c89b5f00b9f75599f2cb138ebab486e51f1c0ac523216085e48b11d8
title: Load a Static Resource Example
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/http-connector/1.10/http-load-static-res-task.md
canonical_url: https://docs.mulesoft.com/http-connector/1.10/http-load-static-res-task
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 95034b17a19b195cff86c0506c62f6c44b6dcae3d3e3685867f963758369a82e
description: MuleSoft Documentation Site
release: "1.10"
latest: false
---
---
product: HTTP Connector
version: 1.10
keywords: anypoint, connectors, transports
---

# Load a Static Resource Example

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

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:

![Load a static resource flow](/mulesoft/current/en-us/http-connector/1.10/_images/http-loadresource-flow.png)

## 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.  Click **OK**.

    ![HTTP Listener global configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-startapp-example-1.png)

6.  Drag a **Load static resource** operation to the right of the HTTP **Listener** source.

7.  Set the **Resource base path** field to `/Users/max/Sites/index.html`.

8.  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.

    ![HTTP Load static resource configuration](/mulesoft/current/en-us/http-connector/1.10/_images/http-loadresource-example-1.png)

9.  Save your Mule app.

10. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule
    Application**.

11. 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
<?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](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)

- [Salesforce Help](https://help.salesforce.com)
