/
WebPage.frm
144 lines (126 loc) · 3.27 KB
/
WebPage.frm
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
'#Region "Form"
#if defined(__FB_MAIN__) AndAlso Not defined(__MAIN_FILE__)
#define __MAIN_FILE__
#ifdef __FB_WIN32__
#cmdline "Form1.rc"
#endif
Const _MAIN_FILE_ = __FILE__
#endif
#ifdef __FB_JS__
#define OnClient
#else
#define OnServer
#endif
#ifdef OnClient
#include once "mff/Form.bi"
#include once "mff/CommandButton.bi"
#include once "mff/HTTP.bi"
Using My.Sys.Forms
Type Form1Type Extends Form
Declare Sub CommandButton1_Click(ByRef Sender As Control)
Declare Constructor
Dim As CommandButton CommandButton1
Dim As HTTPConnection HTTP
End Type
Constructor Form1Type
#if _MAIN_FILE_ = __FILE__
With App
.CurLanguagePath = ExePath & "/Languages/"
.CurLanguage = .Language
End With
#endif
' Form1
With This
.Name = "Form1"
.Text = "Form1"
.Designer = @This
.SetBounds 0, 0, 350, 300
End With
' CommandButton1
With CommandButton1
.Name = "CommandButton1"
.Text = "CommandButton1"
.TabIndex = 0
.SetBounds 90, 90, 160, 50
.Designer = @This
.OnClick = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As Control), @CommandButton1_Click)
.Parent = @This
End With
With HTTP
.Name = "HTTP"
.Host = "localhost"
.Port = 8000
End With
End Constructor
#endif
#ifdef OnServer
#include once "mff/Form.bi"
#include once "mff/HTTPServer.bi"
Using My.Sys.Forms
Type frmServerType Extends Form
Declare Sub Server_Receive(ByRef Sender As HTTPServer, ByRef Request As HTTPServerRequest, ByRef Responce As HTTPServerResponce)
Declare Constructor
Dim As HTTPServer Server
End Type
Constructor frmServerType
#if _MAIN_FILE_ = __FILE__
With App
.CurLanguagePath = ExePath & "/Languages/"
.CurLanguage = .Language
End With
#endif
' Form1
With This
.Name = "frmServer"
.Text = "Server"
.Designer = @This
.SetBounds 0, 0, 350, 300
End With
With Server
Server.Name = "Server"
Server.Address = "127.0.0.1"
Server.Port = 8000
Server.Designer = @This
Server.OnReceive = Cast(Sub(ByRef Designer As My.Sys.Object, ByRef Sender As HTTPServer, ByRef Request As HTTPServerRequest, ByRef Responce As HTTPServerResponce), @Server_Receive)
Server.Run
End With
End Constructor
#endif
#ifdef OnClient
Dim Shared Form1 As Form1Type
#if _MAIN_FILE_ = __FILE__
App.DarkMode = True
Form1.MainForm = True
Form1.Show
App.Run
#endif
#endif
#ifdef OnServer
Dim Shared frmServer As frmServerType
#if _MAIN_FILE_ = __FILE__
App.DarkMode = True
frmServer.MainForm = True
frmServer.Show
App.Run
#endif
#endif
'#End Region
#ifdef OnClient
Private Sub Form1Type.CommandButton1_Click(ByRef Sender As Control)
Dim As HTTPRequest Request
Dim As HTTPResponce Responce
Request.ResourceAddress = "Untitled.html"
Request.Body = "{key: value}"
HTTP.CallMethod("POST", Request, Responce)
?Responce.StatusCode, Responce.Body
End Sub
#endif
#ifdef OnServer
Private Sub frmServerType.Server_Receive(ByRef Sender As HTTPServer, ByRef Request As HTTPServerRequest, ByRef Responce As HTTPServerResponce)
If Request.HTTPMethod = "POST" Then
If Request.Body = "{key: value}" Then
Responce.Body = "true"
End If
End If
End Sub
#endif