renderHTML method

Future renderHTML(
  1. String htmlFile
)

Implementation

Future renderHTML(String htmlFile) async {

  try{

    res?.statusCode = HttpStatus.ok;
    res?.headers.contentType =  ContentType.html;

    String filepath = Directory.current.path.toString()+'/templates/'+htmlFile;

    final File file = File(filepath);

    if(await file.exists()){
      try{
        res?.addStream(file.openRead());
        await res?.close();

      }catch(e){
        await sendInternalError();
      }
    }else{
      await sendNotFound();
    }




  }on FileSystemException catch (e){
    res?.write('File Not Found : $e');
    await res?.close();
  }



}