WelcomeToFlask/examples/html-basic/app.py

49 lines
2.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from datetime import datetime
from flask import Flask, render_template
app = Flask(__name__)
FEATURES = [
(
"render_template",
"EN: render_template is a function provided by Flask that renders an HTML template and returns it as a response to a client (browser). Flask uses a template engine called Jinja2. You write HTML files with placeholders or dynamic content, and render_template fills in those placeholders when the page is requested.",
),
(
"render_template",
" فا: این تابع توسط فلسک ارائه شده و کد های اچ تی ام ال را که در پوشه تمپلیتس است رندر می کند، فلسک در واقع از انجین یا موتوری به نام جینجا2 استفاده می کند. شما می توانید فایل های اچ تی ام ال را به صورت مستقیم و یا پویا در فایل های پایتون به اچ تی ام ال وصل کنید و در خواست به صفحاتتون بفرستید",
),
(
"/templates",
"EN: Store HTML files or templates that your Flask app will render. Flask automatically looks here when you call render_template.",
),
(
"/templates",
"فا: ذخیره فایل های اچ تی ام ال و قالب ها در برنامه فلسک خود که رندر خواهد کرد. فلسک اتوماتیک این پوشه را رصد می کند در صورتیکه تابع رندر_تمپلیتس فراخوانی شود",
),
(
"/static",
"EN: Store static files like CSS, JavaScript, images, fonts — anything that doesnt change dynamically. Flask serves files from this folder automatically.",
),
(
"/static",
"فا: تمامی فایل های استاتیک از جمله کد های سی اس اس و جاوا اسکریپت و عکس ها . فونت ها یا مدیا ها را ذخیره می کند که در حال تغییر به صورت پویا نیستند. فلسک این فایل ها را به صورت اتوماتیک برای شما تنظیم کرده و می توانید از مسیر آن استفاده کنید",
),
]
@app.route("/")
def homepage():
"""Render a simple HTML page that uses dynamic data."""
return render_template(
"index.html",
features=FEATURES,
current_time=datetime.utcnow(),
)
if __name__ == "__main__":
app.run(debug=True)