Host a web-app in CompleteFTP
This tutorial will give you two simple examples on how to host web-applications in CompleteFTP.
Before getting started, you need to enable the 'Server-side Javascript (JSS)' property, on the site which is serving up the page.
- From the side-bar menu, select the 'Settings' panel (Professional Edition)
OR select the 'Sites' panel (Enterprise MFT).
- Enable JSS for the site by checking the 'JSS enabled' checkbox in the Site Settings HTTP/HTTPS category.
-
Enable JSS for the user who is the owner of the folder, into which the JSS file will be placed, as follows:
-
Select the 'Users' panel from the side-bar menu.
-
Select the user whose home folder will contain the jss file, e.g. 'JoeSmith'.
Note that the owner of the /Public folder is the user called 'anonymous', which is hidden by default.
To show it, check the 'Show system users/folder/sites' item in the View menu at the bottom left.
-
In the 'User Properties' window, check the 'JSS(Server-side Javascript)' checkbox.
- Click the 'Apply changes' button at the top right of the CompleteFTP Manager.
Now, let's create our own web-application in Javascript.
Example 1
In this example, we create a web-app that simply displays 'Hello world' and is available publicly.
- Create a text file called helloworld.jss with the following content.
response.write("Hello world");
- Save it in C:\ProgramData\Enterprise Distributed Technologies\Complete FTP\Public.
- Since 'anonymous' is the owner of /Public, JSS must be enabled for that user, as described above.
- Now navigate to http://localhost/helloworld.jss. A web-page simply saying 'Hello world' will show up.
Example 2
In this example, we're going to create a .jss file in a user's home directory, and execute it as a JSS
web application. This web-app will be available only to the user.
- Create a file called listFiles.jss with the following content:
response.write("<h1>" + system.user.homeFolder + "</h1>");
response.write("");
var homeFolder = system.getFile(system.user.homeFolder)
var files = homeFolder.getFiles();
files.forEach(function(file) {
response.write("- " + file.name + "
")
});
response.write("
");
- Save it in JoeSmith's home directory, i.e. C:\ProgramData\Enterprise Distributed Technologies\Complete FTP\Users\JoeSmith.
- Enable JSS for the JoeSmith user, as described above.
- Then go to the URL http://localhost/Home/joesmith/listFiles.jss, where you should see a listing of all the files in that directory.
For more information on developing the JSS web-app, please refer to JSS Web-App Basics and the JSS API Guide.