mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-11-29 21:33:26 -05:00
add a simple browser based demo
Signed-off-by: hrj <harshad.rj@gmail.com>
This commit is contained in:
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user