
html-scala是一个简单、轻量级的服务器,用于将Scala代码转换为HTML。该项目源于使用Scala构建React组件的需求,底层基于https://github.com/lihaoyi/scalatags%E5%BA%93%E3%80%82%E9%80%9A%E8%BF%87%E6%AD%A4%E9%95%9C%E5%83%8F%EF%BC%8C%E7%94%A8%E6%88%B7%E5%8F%AF%E5%B0%86%E7%AC%A6%E5%90%88%E7%89%B9%E5%AE%9A%E6%A0%BC%E5%BC%8F%E7%9A%84Scala%E4%BB%A3%E7%A0%81%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%AF%B9%E5%BA%94%E7%9A%84HTML%E8%BE%93%E5%87%BA%EF%BC%8C%E5%85%B7%E4%BD%93%E8%BD%AC%E6%8D%A2%E8%A7%84%E5%88%99%E5%8F%AF%E5%8F%82%E8%80%83scalatags%E6%96%87%E6%A1%A3%E3%80%82
/transpile
通过POST请求将Scala代码转换为HTML。请求需包含JSON格式的payload:
json{ "code": "需要转换的Scala代码" }
重要:代码必须按照示例格式编写,使用ReactComponent类。
/status
通过GET请求检查服务状态。服务正常时返回200状态码。
Scala代码示例
scalanew ReactComponent { def messageOfTheDay() = "Hello World!" override def render(): Text.TypedTag[String] = { div( h1("Amazing Title"), div( p("Message of the day: " + messageOfTheDay()), p("This is the first paragraph."), p("This is the second paragraph.") ) ) } }
生成的HTML结果
html<div> <h1>Amazing Title</h1> <div> <p>Message of the day: Hello World!</p> <p>This is the first paragraph.</p> <p>This is the second paragraph.</p> </div> </div>
该服务器的Docker镜像可在Docker Hub获取:https://hub.docker.com/r/julianbrendl/html-scala/
bashdocker run -d -p 8080:8080 julianbrendl/html-scala
服务启动后,可通过以下命令检查状态:
bashcurl http://localhost:8080/status
若返回200状态码,表明服务运行正常。
使用curl发送POST请求进行代码转换:
bashcurl -X POST http://localhost:8080/transpile \ -H "Content-Type: application/json" \ -d '{"code": "new ReactComponent { override def render(): Text.TypedTag[String] = div(p(\"Hello from html-scala\")) }"}'
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。



探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务