DEV Community

Lucian Green
Lucian Green

Posted on • Edited on

How to Create a Small Web App with SSI Web Service

I will break down the steps to create a web app with State Saving Interpreter Web Service, an interpreter written in Prolog that runs List Prolog.

  1. Convert the Prolog algorithm to List Prolog

I installed Prolog-to-List-Prolog from https://github.com/luciangreen/Prolog-to-List-Prolog.

In a new file, test1.pl in the Prolog-to-List-Prolog folder, I entered:

cultivate_person(A,B).
cultivate_person(A,B):-writeln("Do you create the person?"),read_string(A),writeln("Do you switch them on to existing for the rest of their life?"),read_string(B).

Then:
['p2lpconverter.pl'].
['../listprologinterpreter/listprolog'].
p2lpconverter(A),pp0(A,B),writeln1(B).

The output is:

"[
[[n,cultivate_person],[[v,a],[v,b]]],
[[n,cultivate_person],[[v,a],[v,b]],"":-"",
[
[[n,writeln],[""Do you create the person?""]],
[[n,read_string],[[v,a]]],
[[n,writeln],[""Do you switch them on to existing for the rest of their life?""]],
[[n,read_string],[[v,b]]]
]]
]"

  1. Modify ssi-api.pl and Run Application

I installed SSI from https://github.com/luciangreen/SSI.

In a new file test1.pl in SSI I entered:

test1([[n,cultivate_person],[[v,a],[v,b]]],

    [[[n,cultivate_person],[[t,string],[t,string]]]],
    [[[n,cultivate_person],[output,output]]],
Enter fullscreen mode Exit fullscreen mode

[[[n,cultivate_person],[[v,a],[v,b]],":-",
[
[[n,writeln],["Do you create the person?"]],
[[n,read_string],[[v,a]]],
[[n,writeln],["Do you switch them on to existing for the rest of their life?"]],
[[n,read_string],[[v,b]]]
]]]).

This includes the output from the first step and optional type and mode statements. Note: two double quotes have been replaced with one. Also, the query was cut from within the brackets as you can see.

In ssi-api.pl, I changed:

test_open_types_cases(4,Query,Types,Modes,Functions),
international_lucianpl([lang,"en"],Debug,Query,Functions,Result1),

to:
test1(Query,Types,Modes,Functions),
international_lucianpl([lang,"en"],Debug,Query,Types,Modes,Functions,_Result),

Then:
[ssi].
[test1].
ssi_server(8000).

In my web browser, I visited my localhost at http://127.0.0.1:8000/.

And here is an image of the first page of the web app in the browser:
(It reads:
http://127.0.0.1:8000/
Do you create the person?
[Text Box]
Submit Button)

Screen Shot 2022-02-21 at 12 12 57 am

Author: Lucian Green
SSI: https://github.com/luciangreen/SSI

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay