<!DOCTYPE html>
<html>

<head>
  <title>NodeActa WEB</title>
  <style>
	body {
      font-family: Tahoma, sans-serif;
	  font-size: 13px;
    }
	code {
      font-style: italic;
    }
  </style>
</head>

<body>
  <div class="main">
	<h1>NodeActa WEB</h1>
	<p>
	This is your NodeActa WEB index page.<br/>
	When you land on your NodeActa Server address using a web browser, this page will be displayed.<br/>
	In NodeActa Application Center this matches your 'Web' app, so if you need to customize it, that would be the place to start.<br/>
	You can override this with NodeActa Server configuration file. If you specify 'WebRoot' option, NodeActa Server will serve index.html file found at specified location. <br />
	But even than, you can access this page via 'http://yourserver/web/', or any other web app via 'http://yourserver/web/demo/'
	</p>
	<p>
	Web browsers, by default, accesses NodeActa Server using 'anonymous' user.<br/>
	You can grant 'execution' right to 'anonymous' user for desired apps, but in the case you need user authentication, just do a request to 'https://yourserver/' with Basic authentication, like this:<br />
	<pre><code>
	fetch('/some-request', {
	    method: 'POST',
	    headers: { 'Authorization': 'Basic ' + btoa(user + ":" + password) }
	}); 
	</code></pre> 
	<br/>	
	But the best practice is to convert this html to login page and on your login button click trigger POST request to '/login' with parameters 'username', 'password' and optionally 'redirecturl', like this:<br />
	<pre><code>
	&lt;form method="post" action="/login"&gt;
	    &lt;div&gt;
	        &lt;label for="username"&gt;Username&lt;/label&gt;
	        &lt;input type="text" id="username" name="username" required/&gt;
	    &lt;/div&gt;
	    &lt;div&gt;
	        &lt;label for="password"&gt;Password&lt;/label&gt;
	        &lt;input type="password" id="password" name="password" required/&gt;
	    &lt;/div&gt;
	    &lt;input type="hidden" id="redirecturl" name="redirecturl" value="/some-nodeacta-url"/&gt;	    
	    &lt;button type="submit"&gt;Sign in&lt;/button&gt;
	&lt;/form&gt;
	</code></pre> 
	<p>	
	You can also navigate to '/login?redirecturl=some_url_encoded_path' to display built-in NodeActa Server 'login.html'.
	</p>	
	This index.html is an example of a static html content. In the case you need to generate a dynamic html page on NodeActa Server and then feed it to a web browser, you can create a standard NodeActa app with 'index.mjs' file, and in 'run()' method return your generated html.<br />
	Here is an <a href="/web/TestWeb/">example</a>:
	</p>
	<pre><code>
	export class TestWeb extends App {
	    async run() {
	        return `&lt;!DOCTYPE html&gt;
	            &lt;html&gt;
	            &lt;h2&gt;Hello, NodeActa World!&lt;/h2&gt;
	            &lt;div&gt;Time: ${(new Date()).toLocaleTimeString()}&lt;/div&gt;
	            ${(function () { return 'do some java script to produce html'; })()}
	            &lt;p&gt;This HTML was generated by NodeActa Servver.&lt;/p&gt;
	            &lt;/html&gt;`;
	    }
	}
	</code></pre>
  </div>
</body>
</html>