Sheerpower Logo
P.3  Browser Scripting

Dynamic Web Development

Sheerpower can be using as a browser scripting language. The first step is to activate the Sheerpower InterNet Services Web Server SPINS_WEBSERVER, also referred to as the spins webserver:
C:>spins_webserver Sheerpower InterNet Services Web Server SPINS_WEBSERVER V10.135 Copyright (c) 2005-2022 Touch Technologies, Inc. - Thu, 20 Jun 2024 21:19:50 Listening IP address is 0.0.0.0 Spoofed>> "Server: Apache/2.4.52 (Ubuntu)" Port 4, wwwroot is C:\Sheerpower\sphandlers\wwwroot\ Port 80, wwwroot is C:\Sheerpower\sphandlers\wwwroot\
The spins webserver has a lot of startup options. They can be seen by:
spins_webserver -?

On some systems, Windows might ask if it is okay if the spins_webserver accesses the network. Choose yes to continue.

To test that spins is working, type this url into your browser's address bar:
http://localhost/

The browser will respond with:
You made it to the SPINS_WEBSERVER index.html To change the default root folder (for example to c:\inetpub\wwwroot) c:> \Sheerpower\sphandlers\spins_webserver -wwwroot c:\inetpub\wwwroot

Let's run our first Sheerpower script. The source code is in C:\Sheerpower\sphandlers\scripts\sp4gl,
and the program is called:
matrix.spsrc. To run it, use this url:
localhost/matrix.spsrc
When Sheerpower code is run as a script, anything between double brackets is code, all else is html.
Note: Inside a SheerPower script, %include files are treated in a specific way:
  • If the first line of the file contains an HTML tag, the entire content of the file is treated as HTML code and output directly to the browser.
  • If the first line does not contain an HTML tag, the file is processed and executed as SheerPower code.
This distinction allows developers to seamlessly integrate both HTML and SheerPower code within the same application.

Explanation of [[ ]] Syntax in Sheerpower

The [[ ]] syntax in Sheerpower is used to embed Sheerpower code within an HTML document. This allows you to mix server-side logic with client-side HTML seamlessly.

How it Works

  • Opening and Closing [[ ]]:

    Code enclosed within [[ ]] is interpreted and executed as Sheerpower code. This syntax helps distinguish between HTML content and Sheerpower code.

  • Usage in HTML:

    You can use [[ ]] to include loops, conditionals, and other logic directly within your HTML. This is useful for generating dynamic content based on server-side processing.

Benefits

  • Dynamic Content: Easily generate dynamic content based on server-side processing.
  • Seamless Integration: Mix HTML and Sheerpower code without switching contexts.
  • Flexibility: Use loops, conditionals, and other logic within HTML to create flexible and powerful web pages.

This feature is particularly useful in creating dynamic and interactive web applications, where the content can be generated and manipulated server-side before being sent to the client.


Summary: SheerPower's unique handling of %include files bridges the gap between web design and software development. By automatically distinguishing between HTML and code content, it allows webpage designers to focus on creating and maintaining HTML independently, while code developers work on the backend logic. This loose coordination minimizes dependency, enabling both teams to contribute their expertise without requiring detailed knowledge of each other's domain. This feature simplifies collaboration, streamlines development, and ensures seamless integration of design and functionality within a single application.
Below is the HTML code mixed with Sheerpower code.
Note: This code for matrix.spsrc is only runnable from your local computer, inside of your browser.
Hide Description

    

       


      

Enter or modify the code below, and then click on RUN

Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.
Wide screen