Hi I am using vapor for server side with swift programming language. For file serving I correctly configured the middleware in xcode. But index.html
in the folder is not recognisable by server itself. But calling specific file http://127.0.0.1:8080/index.html
works fine.
If I call http://127.0.0.1:8080/
only then there is an error
"open(file:oFlag:mode:): No such file or directory (errno: 2)"
Code:
import Vapor
import FluentSQL
import FluentKit
import FluentMySQLDriver
// configures your application
public func configure(_ app: Application) throws {
app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
app.views.use(.plaintext)
try routes(app)
}
In the routes(_ app: Application)
I used to serve html file by below method but this is also not working and got same error.
app.get("folder") { req in
req.view.render("index.html")
}
How can I serve html file programmatically also How can I make the server index.html
recognisable when calling http://127.0.0.1:8080/
.