serveFromFile method

Future serveFromFile (
  1. HttpRequest request,
  2. String path
)

Implementation

Future serveFromFile(HttpRequest request, String path) async {
  Uri fileUri = Platform.script.resolve(path);
  File file = new File(fileUri.toFilePath());
  bool exists = await file.exists();
  if (exists) {
    return vd.serveFile(file, request);
  } else {
    path = path.replaceFirst("/build", "");
    fileUri = Platform.script.resolve(path);
    file = new File(fileUri.toFilePath());
    if (file.existsSync()) {
      return vd.serveFile(file, request);
    } else {
      var error = new AssistentError("Unable to serve form file to 'pub serve' for '${request.uri}'");
      return new Future.error(error);
    }
  }
}