1 | initial version |
In Flask, the background image can be set in the HTML template file using CSS. Here are the steps to set a background image:
Save the image file in the static folder of your Flask application.
Create a CSS file in the static folder or add the CSS code in the HTML file.
In the CSS code, set the background-image property to the path of the image file:
body {
background-image: url('/static/image_name.jpg');
}
<style>
tag in the head section of the HTML file.<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" />
</head>
<body>
...
</body>
</html>
Note: Make sure to use the correct path to the image and the correct filename in the CSS and HTML code.