prolog-point-of-sale/main.pl

61 lines
1.3 KiB
Perl
Raw Normal View History

2019-11-03 01:05:33 +00:00
:- use_module(library(http/html_head)).
:- use_module(library(http/html_write)).
2019-10-31 23:20:18 +00:00
:- use_module(library(http/http_client)).
2019-11-01 00:13:23 +00:00
:- use_module(library(http/http_header)).
2019-11-03 01:05:33 +00:00
:- use_module(library(http/http_json)).
:- use_module(library(http/http_server)).
:- use_module(library(http/http_session)).
:- use_module(library(http/js_write)).
2019-10-31 23:20:18 +00:00
:- use_module(library(http/json)).
2019-11-03 01:05:33 +00:00
:- use_module(library(http/json_convert)).
2019-10-31 23:20:18 +00:00
:- use_module(library(persistency)).
2019-11-03 23:08:45 +00:00
:- ['routes/login.pl'].
2019-11-04 23:01:38 +00:00
:- ['routes/products.pl'].
2019-11-03 23:08:45 +00:00
:- ['routes/users.pl'].
2019-11-04 23:01:38 +00:00
:- ['views/cart.pl'].
2019-11-03 23:08:45 +00:00
:- ['views/login.pl'].
2019-11-04 23:01:38 +00:00
:- ['views/products.pl'].
2019-11-03 23:08:45 +00:00
hang :-
sleep(600),
hang.
run :-
http_server([port(8080)]),
hang.
2019-11-03 01:05:33 +00:00
2019-10-31 23:20:18 +00:00
:- initialization
absolute_file_name('database.db', File, [access(write)]),
2019-11-03 01:05:33 +00:00
db_attach(File, []),
db_sync_all(gc(always)).
2019-10-31 23:20:18 +00:00
:- json_object
product(name:atom, price:integer).
:- persistent
product(name:atom, price:integer).
2019-11-01 00:13:23 +00:00
:- json_object
login(username:atom, password:atom).
:- json_object
2019-11-01 00:48:35 +00:00
user(username:atom).
2019-11-01 00:13:23 +00:00
:- persistent
user(username:atom, password_hash:atom).
:- json_object
token(username:atom, token:atom).
:- persistent
token(username:atom, token:atom).
2019-11-03 01:05:33 +00:00
:- persistent
session(session:atom, username:atom).
2019-11-01 00:13:23 +00:00
:- json_object
error(error:atom).
2019-11-03 01:05:33 +00:00
reply_prolog(Term) :-
prolog_to_json(Term, Json),
reply_json(Json).
2019-11-03 23:08:45 +00:00