Size: 3343
Comment:
|
Size: 2238
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
Once the MildServer is running on your machine (see MildServer/GettingStarted), you should be able to direct your browser to http://localhost:8080 and see the front page: {{attachment:MildServerIndex.jpg}} The front page is implemented by the file called ''index.dyalog'' in the Demo folder, which has the following content: |
The front page of the MildServer (which you can see by directing your browser to http://localhost:8080) is implemented implemented by the file called ''index.dyalog'' in the Demo folder. It looks like this: |
Line 23: | Line 19: |
The first line declares that this is a Class called ''Index'', which derives from a base class called ''MildPage'' (which you don't need to know about, but in case you are curious, it happens to be implemented by the file ''Core\MildPage.dyalog''). As soon as this page has been viewed for the first time, the class ''Index'' will have been defined in the root of the server workspace. There is also a utility function in the root of the server workspace which you can use to load pages, the page could have been loaded into the workspace by typing (Load 'index'). | The front page is essentially a static page - it is not interactive and does not change, so it could have been implemented using a simple HTML text file. It is only implemented as a scripted page in order to provide a very simple example to discuss. |
Line 25: | Line 21: |
The example is discussed in more detail on the next page: [[MildServer/SampleIndex|Samples: The index page]]. | The HTMLInput class is included so that we can use the {{{Enclose}}} function to wrap the header in an 'h2' (header level 2) tag, and the body text in a 'p' (paragraph) tag. The body text itself is retrieved from the file ''welcome.txt'. Finally, the HTML is passed to req.Return, producing the following output: |
Line 27: | Line 23: |
To debug a page as it runs, the easiest thing to do is to insert an intentional error into the code. When you next refer to the page using a browser, the code will crash on your error and the Dyalog debugger will open up. You can now trace through the code and change it. Each time you exit from the function editor, you will be asked whether you want to overwrite the source file, or only make the change in the active workspace. | {{attachment:MildServerIndex.jpg}} |
Line 29: | Line 25: |
'''IMPORTANT:''' When resuming after editing a function, always use the GREEN button in the tracer ("Restart all threads"). By default, APL will halt all threads on an error - and this includes the main listener thread. If you don't restart all threads, the server will stop responding to requests. If the server stops responding, try the menu item ''Threads|Resume all threads'' to see whether the main thread is paused. | The HTML returned is the following (the ''html'' tags and the ''head'' section are added by the ''Wrap'' method in the class defined by ''Code\DemoServer.dyalog'' Class). {{{ <html><head> |
Line 31: | Line 29: |
== Using External Editors == If you have a Unicode keyboard or the Dyalog IME installed, you can also edit the pages using Notepad or other text editors. The MildServer will check the timestamp of the source file on each request and reload the source if it has changed. |
<title>Demo Server</title> <link href="/Styles/Style.css" rel="stylesheet" type="text/css"> </head> <body><h2>Welcome to MildServer</h2> <p><i>Anyone who can write an APL function should be able to make it available on the Internet.</i><br><br> This is the goal of the <a href="http://aplteam2.com/aplwiki/MildServer">MildServer Project</a>. You can read more about the project and download source code from the <a href="http://aplwiki.aplteam.com">APL Wiki</a>.<br><br> |
Line 34: | Line 40: |
'''Beware:''' If you ''alternate'' between editing the class in the worspace and using an external editor, note that some simple editors (like Notepad) will NOT detect changes to the file made by another program. This means that, if you have the file open in Notepad and make a change in APL, the file will be updated but Notepad will '''NOT''' notice. If you subsequently make changes in Notepad and save the file, you will lose the changes made previously in APL. If you save a change in Notepad and subsequently edit the file in APL, you will be warned when you try to save the file from APL that the source file has changed since it was loaded: If you get this warning you need to check what changes were made and find a way to merge these changes together. * Continue to [[MildServer/SampleIndex|Samples: To read more about the index page]]. * Return to the main MildServer page. |
Click on one of the following links to run MildServer sample pages: <ul> <li><a href="/reverse?Name=Beethoven">Roll over Beethoven!</a></li> <li><a href="/mmind/MMind.dyalog?">Animal Mastermind</a></li> <li><a href="/linreg">Linear Regression</a></li> <li><a href="Admin/httprequest">HTTPRequest Content Demo</a></li> <li><a href="Admin/sessioninfo">SimpleSession Information Demo</a></li> </ul> </p> </body></html> }}} |
The front page of the MildServer (which you can see by directing your browser to http://localhost:8080) is implemented implemented by the file called index.dyalog in the Demo folder. It looks like this:
:Class Index : MildPage :Include #.HTMLInput ∇ Render req;html;links;hdr :Access Public hdr←'h2'Enclose'Welcome to MildServer' html←#.Files.GetText req.Server.Root,'welcome.txt' req.Return hdr,'p' Enclose html ∇ :EndClass
The front page is essentially a static page - it is not interactive and does not change, so it could have been implemented using a simple HTML text file. It is only implemented as a scripted page in order to provide a very simple example to discuss.
The HTMLInput class is included so that we can use the Enclose function to wrap the header in an 'h2' (header level 2) tag, and the body text in a 'p' (paragraph) tag. The body text itself is retrieved from the file welcome.txt'. Finally, the HTML is passed to req.Return, producing the following output: The HTML returned is the following (the
<html><head>
<title>Demo Server</title>
<link href="/Styles/Style.css" rel="stylesheet" type="text/css">
</head>
<body><h2>Welcome to MildServer</h2>
<p><i>Anyone who can write an APL function should be able
to make it available on the Internet.</i><br><br>
This is the goal of the
<a href="http://aplteam2.com/aplwiki/MildServer">MildServer Project</a>.
You can read more about the project and download source code from the
<a href="http://aplwiki.aplteam.com">APL Wiki</a>.<br><br>
Click on one of the following links to run MildServer sample pages:
<ul>
<li><a href="/reverse?Name=Beethoven">Roll over Beethoven!</a></li>
<li><a href="/mmind/MMind.dyalog?">Animal Mastermind</a></li>
<li><a href="/linreg">Linear Regression</a></li>
<li><a href="Admin/httprequest">HTTPRequest Content Demo</a></li>
<li><a href="Admin/sessioninfo">SimpleSession Information Demo</a></li>
</ul>
</p>
</body></html>