Skip to content

Instantly share code, notes, and snippets.

View kaustubhgupta's full-sized avatar
🏘️
On vacation

Kaustubh Gupta kaustubhgupta

🏘️
On vacation
View GitHub Profile
<h3>{{not_defined|default("This is not defined in the Main program")}}</h3>
<h3>{{marks|dictsort(by='value')}}</h3>
<h3>{{5456151|filesizeformat}}</h3>
{{html_format|safe}}
<h3>"This is a sample text which will be displayed on the website": {{"This is a sample text which will be displayed on the website"|truncate(20)}}</h3>
<h3>"This is a sample text which will be displayed on the website": {{"This is a sample text which will be displayed on the website"|truncate(20, true)}}</h3>
<h3>{{"https://github.com/kaustubhgupta"|urlize}}</h3>
<h3>"This is a sample text which will be displayed on the website": {{"This is a sample text which will be displayed on the website"|wordcount}}</h3>
<h3>String Type (Upper Function): {{string_.upper()}}</h3>
<h3>Integer Type (Arithemtic Function): {{integer + 2}}</h3>
<h3>List Type (Slicing): {{skills[1]}}</h3>
<h3>Dictionary Type (Get Function): {{dictionary.get('2nd_year')}}</h3>
<h3>Class Type (Instance Function): {{class_.getMaxSpeed()}}</h3>
<h3>Set Type (Intersection Function): {{set_1.intersection(set_2)}}</h3>
from flask import Flask, render_template
app = Flask(__name__)
class Car:
def __init__(self, name: str, engine: str) -> None:
self.name = name
self.engine = engine
def getMaxSpeed(self) -> int:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
return render_template('new.html',
first_name='Kaustubh',
last_name="Gupta",
article_title="Jinja Template ")
from flask import Flask
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
return "Hello"
if __name__ == "__main__":
app.run(debug=True)
<!doctype html>
<html lang="en">
<head>
<title>{{title}}</title>
</head>
<body>
{{body_content}}
<img src="/static/img1.png">
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles
from fastapi.responses import HTMLResponse
import uvicorn
app = FastAPI()
staticfiles = StaticFiles(directory="demo/toServe")
app.mount("/static", staticfiles, name="static")
templates = Jinja2Templates(directory="demo")
<!doctype html>
<html lang="en">
<head>
<title>{{title}}</title>
</head>
<body>
{{body_content}}
</body>
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
from fastapi.responses import HTMLResponse
import uvicorn
app = FastAPI()
templates = Jinja2Templates(directory="demo")
@app.get('/', response_class=HTMLResponse)
from fastapi import FastAPI
from book import bookroute
from novel import novelroute
import uvicorn
app = FastAPI()
app.include_router(bookroute, prefix="/book")
app.include_router(novelroute, prefix="/novel")