-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib.ua
79 lines (69 loc) · 1.22 KB
/
lib.ua
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Xml ~ "xml" ~ ! Tags!
~ "xml" ~ ! Tags!
Listener ← &tcpl "0.0.0.0:8080"
HXGet ← $$ hx-get="_"
HXPost ← $$ hx-post="_"
HXSwap ← $$ hx-swap="_"
HXTarget ← $$ hx-target="_"
# ? Status Mime Bytes
Response ← (
⊙⊙(⧻.)
$$ HTTP/1.1 _
$$ Content-Type: _
$$ Content-Length: _
$$
$$
⊂ utf₈
)
ResHTML ← (Response "200 OK" "text/html" utf₈)
Respond! ← ◌pool(
&p $"Request from _" &tcpaddr.
# Extract path from request
°□⊡1 ⊜□≠@\s . &ru "\r\n\r\n".
&p $"Request:\n_".
^0
&p⊸($"Response: _ bytes" ⧻)
# Send response
⊃⋅&cl&w
)
Serve! ← ⍢(⍣Respond!(^0)⋅&p &tcpa Listener)1
Tags!(
A
| B
| Body
| Br
| Button
| Div
| Em
| Form
| Head
| Html
| H₁
| H₂
| H₃
| H₄
| H₅
| H₆
| I
| Li
| Meta
| Ol
| P
| Span
| Strong
| Style
| Table
| Title
| Ul
| Script
)
┌─╴test
⍤⤙≍ "<p>abc</p>" P "abc"
⍤⤙≍ "<p>abc</p>" P {"abc"}
⍤⤙≍ "<h2>x</h2>" H₂ "x"
⍤⤙≍ "<h2>x</h2>" H₂ {"x"}
⍤⤙≍ "<p a=3 b=5 c=\"wow\">abc</p>" P {!a+1 2 !b5 !c"wow" "abc"}
⍤⤙≍ "<p><span>text</span></p>" P Span "text"
⍤⤙≍ "<p><span>text</span></p>" P {Span {"text"}}
⍤⤙≍ "<p><span>text</span></p>" P {Span {"text"}}
└─╴