use crate::prelude2::*;
use qrcode::render::svg;
use qrcode::QrCode;
pub async fn qrcode_index(request: HttpRequest) -> impl Responder {
let mut ctx = tera::Context::new();
let image1 = QrCode::new(
b"https://stackoverflow.com/questions/3206344/passing-html-to-template-using-flask-jinja2",
)
.unwrap()
.render()
.min_dimensions(200, 200)
.dark_color(svg::Color("#000000"))
.light_color(svg::Color("#ffffff"))
.build();
let image2 = QrCode::new(
b"https://stackoverflow.com/questions/3206344/passing-html-to-template-using-flask-jinja2",
)
.unwrap()
.render()
.min_dimensions(200, 200)
.dark_color(svg::Color("#000000"))
.light_color(svg::Color("#ffffff"))
.build();
let image3 = QrCode::new(b"http://127.0.0.1:8000/developer/qrcode")
.unwrap()
.render()
.min_dimensions(200, 200)
.dark_color(svg::Color("#000000"))
.light_color(svg::Color("#ffffff"))
.build();
ctx.insert("qrcode_svg1", &image1);
ctx.insert("qrcode_svg2", &image2);
ctx.insert("qrcode_svg3", &image3);
request.render(200, "qrcode/qrcode_index.html", ctx)
}