Swift – 使用HTML的蒸汽

前端之家收集整理的这篇文章主要介绍了Swift – 使用HTML的蒸汽前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我最近从Perfect切换到Vapor.In Perfect你可以做这样的事情而不使用html文件.

routes.add(method: .get,uri: "/",handler: {
    request,response in
    response.setHeader(.contentType,value: "text/html")
    response.appendBody(string: "

在Vapor中我发现返回html的唯一方法就是这样做.如何在不使用蒸汽中的html文件的情况下返回HTML代码

 drop.get("/") { request in
    return try drop.view.make("somehtmlfile.html")
} 
最佳答案
您可以构建自己的Response,完全避免视图.

drop.get { req in
  return Response(status: .ok,headers: ["Content-Type": "text/html"],body: "

要么

drop.get { req in
  let response = Response(status: .ok,body: "

原文链接:https://www.f2er.com/html/426256.html

猜你在找的HTML相关文章