Do other Python packages have functions such as render_template in Flask?

Asked 2 years ago, Updated 2 years ago, 65 views

Hello.

I would like to send an email to Python this time.

Create html files in advance I want to make html code by delivering the factor value like the render_template of flask.

tmpHtml = render_template("welcome.html" , username="tius1234")

When I tried to use the render_template of the flask, it couldn't work with the simple main() program, and I had to use it in the same form as the app.run()...

So I'm looking for another way.

Or is it possible to implement functions such as crontab using flask? The flask I know is a response through url call.

If you can use it on the flask, I don't think that's a problem. (Sending mail every hour of a certain cycle, etc.))

I ask for your help me.

Then have a good day today.

python flask render_template

2022-09-21 21:07

2 Answers

To implement features like CronTab You can use a module called aps. flask extension also exists.

In the case of template engine, jinja2 template seems to be a good choice because there are many implementations in other languages.


2022-09-21 21:07

Somehow, I found it.

import jinja2

tmpHtml = jinja2.Environment(loader=jinja2.FileSystemLoader("PATH")).get_template("FILE").render({username:"tius1234"})

If you know a better way, please give us your opinion ^

^


2022-09-21 21:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.