def server():

        # Create the flowData object for the JSON route
        flowData = pipeline.create_flowdata()

        # Add any information from the request (headers, cookies and additional 
        # client side provided information)

        flowData.evidence.add_from_dict(webevidence(request))

        # Process the flowData

        flowData.process()

        # Generate the HTML
        output = ""

        # Add the JavaScript created by the pipeline
        output += "<script>"
        output += flowData.javascriptbuilder.javascript
        output += "</script>"


        output += "<h1>Client side evidence</h1>"

        # Print a button which gets the user's location information
        # This is then sent to the previously specified json endpoint
        # Data comes back from the request and populates the country in the HTML

        output += """

        <p>After you select the "use my location" button below, client side JavaScript will
        update the country field using this information.</p>

        <p>Country: <span id=country></span></p>

        <button type="button" onclick="getLocation()">Use my location</button>

        <script>

        let getLocation = function() {
            fod.complete(function (data) {
                document.getElementById("country").innerHTML = data.location.country
            }, 'location');
        }
            
        </script>


        """

        return output
    def jsonroute():

        # Create the flowData object for the JSON route
        flowData = pipeline.create_flowdata()

        # Add any information from the request (headers, cookies and additional 
        # client side provided information)

        flowData.evidence.add_from_dict(webevidence(request))

        # Process the flowData
        flowData.process()

        # Return the JSON from the JSONBundler engine
        return json.dumps(flowData.jsonbundler.json)
def processRoute():
    # Create the flowdata object for the JSON route
    flowdata = pipeline.create_flowdata()

    # Add any information from the request (headers, cookies and additional
    # client side provided information)
    flowdata.evidence.add_from_dict(webevidence(request))

    # Process the flowdata
    flowdata.process()

    # Generate the HTML
    output = "<h2>Process Example</h2><br/>\n"
    output += "<b>Is Mobile:</b> " + str(
        getValueHelper(flowdata, "device", "ismobile"))
    output += "<br />"

    return output
def server():
    
    flowdata = myPipeline.create_flowdata()

    # Add any information from the request (headers, cookies and additional 
    # client side provided information)

    flowdata.evidence.add_from_dict(webevidence(request))

    # Process the flowdata

    flowdata.process()

    # Generate the HTML for the form that gets a user's starsign 

    output = ""

    output += "<h1>Starsign</h1>"

    output += "<form><label for='dateOfBirth'>Date of birth</label><input type='date' name='dateOfBirth' id='dateOfBirth'><input type='submit'></form>"

    ## Add the results if they're available

    if (flowdata.astrology.starSign):
        output += "<p>Your starsign is " + flowdata.astrology.starSign + "</p>"

    output += "<div id='hemispheretext'>"

    if (flowdata.astrology.hemisphere):
        output += "<p>Look at the " + flowdata.astrology.hemisphere + " hemisphere stars tonight!</p>"

    output += "</div>"

    output += "<script>"

    ## This function will fire when the JSON data object is updated
    ## with information from the server.
    ## The sequence is:
    ## 1. Response contains JavaScript property 'getLatitude' that gets executed on the client
    ## 2. This triggers another call to the webserver that passes the location as evidence
    ## 3. The web server responds with new JSON data that contains the hemisphere based on the location.
    ## 4. The JavaScript integrates the new JSON data and fires the onChange callback below.

    output += flowdata.javascriptbuilder.javascript

    output += """
        const loadHemisphere = function() {
            fod.complete(function (data) {  
                if(data.astrology.hemisphere) {          
                    var para = document.createElement("p");
                    var text = document.createTextNode("Look at the " + 
                        data.astrology.hemisphere + " hemisphere stars tonight");
                    para.appendChild(text);

                    var element = document.getElementById("hemispheretext");
                    var child = element.lastElementChild;  
                    while (child) { 
                        element.removeChild(child); 
                        child = element.lastElementChild; 
                    } 
                    element.appendChild(para);
                }
            })
            };
            
            """

    output += "</script>"

    # Return the full output to the page

    return output