Browse Source

Added SWI-Prolog Http Server (#6134)

* Added SWI-Prolog Http Server

* Update travis.yml

* Fixed build failure and added README

* Update README
Sumeet Chhetri 4 years ago
parent
commit
1bba2dda55

+ 1 - 0
.travis.yml

@@ -70,6 +70,7 @@ env:
     - 'TESTDIR="PHP/cakephp PHP/codeigniter PHP/fat-free PHP/fuel PHP/phpixie PHP/slim PHP/symfony PHP/yii2 PHP/zend PHP/spiral PHP/duckphp"'
     - 'TESTDIR="PHP/amp PHP/hhvm PHP/peachpie PHP/php-ngx PHP/phalcon"'
     - 'TESTDIR="PHP/hamlet PHP/laravel PHP/lumen PHP/swoole PHP/ubiquity PHP/hyperf PHP/sw-fw-less PHP/imi PHP/simps PHP/one"'
+    - "TESTLANG=Prolog"
     - 'TESTDIR="Python/aiohttp Python/api_hour Python/apidaora Python/blacksheep Python/bottle Python/cherrypy Python/crax Python/django Python/emmett Python/eve Python/falcon Python/fastapi Python/flask"'
     - 'TESTDIR="Python/hug Python/japronto Python/klein Python/morepath Python/pyramid Python/quart Python/responder Python/sanic Python/spyne Python/starlette"'
     - 'TESTDIR="Python/tornado Python/turbogears Python/uvicorn Python/uwsgi Python/vibora Python/web2py Python/webware Python/weppy Python/wsgi"'

+ 8 - 0
frameworks/Prolog/SWI-Prolog/README

@@ -0,0 +1,8 @@
+Prolog is a logic programming language associated with artificial intelligence and computational linguistics
+
+SWI-Prolog is a free implementation of the programming language Prolog, commonly used for teaching and semantic web applications
+
+This implementation uses the [HTTP Server libraries](https://www.swi-prolog.org/pldoc/man?section=httpserver) available with SWI-Prolog
+
+Currently only the /json and /plaintext endpoints have been implemented
+

+ 25 - 0
frameworks/Prolog/SWI-Prolog/benchmark_config.json

@@ -0,0 +1,25 @@
+{
+	"framework": "swi-prolog",
+	"tests": [{
+		"default": {
+			"json_url": "/json",
+			"plaintext_url": "/plaintext",
+			"port": 8080,
+			"approach": "Realistic",
+			"classification": "None",
+			"database": "None",
+			"framework": "SWI-Prolog",
+			"language": "Prolog",
+			"orm": "None",
+			"platform": "None",
+			"webserver": "SWI-Prolog",
+			"os": "Linux",
+			"database_os": "Linux",
+			"display_name": "SWI-Prolog",
+			"notes": "",
+			"versus": "",
+			"tags": []
+		}
+	}]
+}
+

+ 38 - 0
frameworks/Prolog/SWI-Prolog/server.pl

@@ -0,0 +1,38 @@
+:- module(server,
+      [ server/1            % ?Port
+      ]).
+
+:- use_module(library(http/thread_httpd)).
+:- use_module(library(http/http_dispatch)).
+:- use_module(library(http/http_unix_daemon)).
+:- use_module(library(http/http_dyn_workers)).
+
+%!  server(+Port) is det.
+%
+%   Start the server at Port.
+
+server(Port) :-
+    server(Port,
+           [ workers(10)
+           ]).
+
+server(Port, Options) :-
+    http_server(http_dispatch,
+                [ port(Port),
+                  timeout(20)
+                | Options
+                ]).
+
+:- http_handler('/plaintext', plaintext, [chunked]).
+:- http_handler('/json', json, [chunked]).
+
+plaintext(_Request) :-
+    format('Server: SWI-Prolog~n'),
+    format('Content-type: text/plain~n~n'),
+    format('Hello, World!').
+
+json(_Request) :-
+    format('Server: SWI-Prolog~n'),
+    format('Content-type: application/json~n~n'),
+    format('{"message":"Hello, World!"}').
+

+ 16 - 0
frameworks/Prolog/SWI-Prolog/swi-prolog.dockerfile

@@ -0,0 +1,16 @@
+FROM ubuntu:20.04
+
+ENV IROOT=/installs
+
+ENV DEBIAN_FRONTEND noninteractive
+RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
+
+RUN apt update -yqq && apt-get install -y software-properties-common
+RUN apt-add-repository ppa:swi-prolog/stable -y
+RUN apt-get update -y && apt-get install -y --no-install-recommends swi-prolog
+
+COPY server.pl ${IROOT}/
+WORKDIR ${IROOT}
+
+CMD swipl server.pl --user=daemon --fork=false --port=8080
+