forked from MLstate/hello_recaptcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello_recaptcha_app.opa
42 lines (37 loc) · 934 Bytes
/
hello_recaptcha_app.opa
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
import tutorial.recaptcha
/**
* A test configuration for the reCaptcha, based on a public/private key pair
* registered for "example.com".
*/
server private config =
{
cfg_private: {
privkey: "6LdVTcQSAAAAAJGuyHbunFigtJ1HuI1nkVtwAahg"
},
cfg_public: {
pubkey: "6LdVTcQSAAAAABMAPRuRawMTsX0vfW2O2c3bDeeL",
theme: {some: "red"}
}
}
/**
* After validation, just display the result.
*/
function after_validation(res) {
match (res) {
case { success: _ }: #status = <>success</>;
case { failure: _ }: #status = <>failure</>;
}
}
function page() {
(implementation, recaptcha) = Recaptcha.make(config);
<div>
Are you a human being?<br />
{recaptcha}
<button onclick={function(_) { Recaptcha.validate(implementation, after_validation)}}> Submit </button>
<div id=#status></div>
</div>;
}
/**
* Main application.
*/
Server.start(Server.http, {title: "Hello, Recaptcha", ~page});