Skip to main content

Posts

Showing posts with the label Jinja-Templates

Save Rendered Templates in Flask

 Flask:     We can return multiple types of responses using flask like HTTP Responses , XML responses and Templates responses. Consider the use case like you wanted to save html pages which are dynamically rendered    Packages required: 1. jinja2 2. Flask   Create a Folder structure:     Template        |-   image        |-   fonts        |-   js          index.html   index.html: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>{{name}}</h1> <p>{{address}}</p> </body> </html>     code: #imports from jinja2 import Environment , select_autoescape , FileSystemLoader #fetch the index.html file using the FilesystemLoader path = os . path . dirname ( os . path . abspath ( __file_...