-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.wls
More file actions
64 lines (35 loc) · 1 KB
/
Copy pathTest.wls
File metadata and controls
64 lines (35 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(* :Package: *)
(*```
cd ~/Projects
git clone https://github.com/WLJSTeam/Objects.git
git clone https://github.com/WLJSTeam/Internal.git
git clone https://github.com/WLJSTeam/HTTP.git
git clone https://github.com/WLJSTeam/CSockets.git
```*)
projectsDirectory = FileNameJoin[{$HomeDirectory, "Projects"}];
pacletDirectories = Map[FileNameJoin[{projectsDirectory, #}]&] @ {
"Objects",
"Internal",
"HTTP",
"CSockets"
};
Map[PacletDirectoryLoad, pacletDirectories];
Get["WLJS`CSockets`"];
Get["WLJS`HTTP`"];
Get["WLJS`Internal`"];
Get["WLJS`Objects`"];
(*low level API*)
server = CSocketOpen[8080];
handler = CSocketHandler[]
handler["DefaultHandler"] = Function[
Echo[#Data];
"HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 12\r\n\r\nWLJS Server."
];
(*http level API*)
http = HTTPHandler[];
http["MessageHandler", "GETFILE"] = GetFileRequestQ["html"] -> ImportFile;
(*entry point*)
SocketListen[server, handler];
While[True,
Pause[10];
];