diff --git a/README.md b/README.md index 5d19266..1e93345 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ The sample CAPTCHAs are also just that, samples. They have not been tested again 1. Download the `jar` file from the latest release 2. Type `mkdir data/`. (The data directory is used to store a config file that you can tweak, and for storing the Database) -2. Type `java -jar LibreCaptcha.jar` +3. Type `java -jar LibreCaptcha.jar` +4. Open [localhost:8888/demo/index.html](http://localhost:8888/demo/index.html) in browser We recommend a Java 11+ runtime as that's what we compile the code with. @@ -32,6 +33,7 @@ Alternatively, 1. Install [sbt](https://www.scala-sbt.org/) 2. Clone this repository 3. Type `sbt run` within the repository +4. Open [localhost:8888/demo/index.html](http://localhost:8888/demo/index.html) in browser ## Quick start with Docker @@ -51,7 +53,9 @@ docker run -v lcdata:/lc-core/data librecaptcha/lc-core:latest A default `config.json` is automatically created in the mounted volume. ## Quick test -To test the installation, try: +Open [localhost:8888/demo/index.html](http://localhost:8888/demo/index.html) in browser. + +Alternatively, on the command line, try: ``` > $ curl -d '{"media":"image/png","level":"easy","input_type":"text"}' localhost:8888/v1/captcha diff --git a/src/main/resources/index.html b/src/main/resources/index.html new file mode 100644 index 0000000..4ab40ff --- /dev/null +++ b/src/main/resources/index.html @@ -0,0 +1,69 @@ + + + + + +
+
+ Level + +
+
+ Media + +
+
+ Input Type + +
+
+ +
+
+
+
...
+
+ + + \ No newline at end of file diff --git a/src/main/scala/lc/server/Server.scala b/src/main/scala/lc/server/Server.scala index 9b959a1..cd7995d 100644 --- a/src/main/scala/lc/server/Server.scala +++ b/src/main/scala/lc/server/Server.scala @@ -7,6 +7,8 @@ import lc.core.{Parameters, Id, Answer, Error, ByteConvert} import lc.core.Config.formats import org.limium.picoserve import org.limium.picoserve.Server.ByteResponse +import scala.io.Source +import org.limium.picoserve.Server.StringResponse class Server(port: Int) { val server: picoserve.Server = picoserve.Server.builder() @@ -35,6 +37,11 @@ class Server(port: Int) { val result = Captcha.checkAnswer(answer) getResponse(result) }) + .GET("/demo/index.html", (_) => { + val resStream = getClass().getResourceAsStream("/index.html") + val str = Source.fromInputStream(resStream).mkString + new StringResponse(200, str) + }) .build() private def getResponse(response: Either[Error, ByteConvert]): ByteResponse = {