shell pip install Jinja2 pip install jinja-assets-compressor html <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="{{ assets.url('css/style1.css') }}"> <link rel="stylesheet" href="{{ assets.url('css/style2.css') }}"> </head> <body> <script src="{{ assets.url('js/script1.js') }}"></script> <script src="{{ assets.url('js/script2.js') }}"></script> </body> </html> python from jinja2 import Environment, FileSystemLoader from jinja_assets_compressor import CompressorExtension env = Environment(loader=FileSystemLoader('/path/to/templates')) env.add_extension(CompressorExtension) python from config import env template = env.get_template('index.html') output = template.render() print(output) shell python main.py


上一篇:
下一篇:
切换中文