Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtuosoChess authored Jul 29, 2024
1 parent dd7a880 commit 833a904
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ui/analyse/src/APIroute.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Route

object ApiRoutes {
val route: Route =
pathPrefix("api") {
path("analyze" / "tablebase") {
parameters('fen) { fen =>
complete {
TablebaseService.getTablebaseEvaluation(fen).map { result =>
HttpEntity(ContentTypes.`application/json`, s"""{
"bestMove": "${result.bestMove}",
"evaluation": ${result.wdl},
"dtz": ${result.dtz}
}""")
}
}
}
} ~
path("practice" / Segment) { theme =>
get {
val position = PracticeService.generatePracticePosition(theme)
complete(HttpEntity(ContentTypes.`application/json`, s"""{"fen": "$position"}"""))
}
}
}
}

0 comments on commit 833a904

Please sign in to comment.