TIL Python Basics Day 56 - Rendering HTML/Static files and Using Website Templates

이다연·2021년 2월 10일
0

Udemy Python Course

목록 보기
52/64

Rendering HTML templates


make a seperate directory 'templates'
Store index.html file,
and return render_template('index.html') in server.py

from flask import render_template

@app.route('/')
def home():
    return render_template('index.html')

if downloaded html file from web, it might be .htm -> change it to .html

Static files and Using Website Templates

static files needs to be inside static folder
static files: css, image, video files

1. image

specify directory in <img src= "static/ ~

<td><img src="static/angela.png" alt="angela profile picture"></td>

2. css

create a css file in static file

main.css

body {
	background-color: purple
}

Link relationship to html at head part

index.html

<link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}">

Note: browsers like to cache -> on the same day, it won't change over one day.

solution: hard reload -> shift + refresh button

캐시
웹 캐시는 자주 쓰이는 문서의 사본을 자동으로 보관하는 HTTP 장치

Prebuilt Templates

https://html5up.net/

Change the directories accordingly -> ctrl + R for mass change

module 461 for Chrome developer tools for modifying on screen. After editing save the html and add it to your file.

Project. Digital Name Card

  • Downloaded html template from here
  • Changed SNS icons
  • Resized the image
    img {
    width: 100%;
    height: auto;
    }

I marked 70% progress in the online lecture. I've been studying for 60 days by myself. I've started it since January with 100 days challenge. My daily routine is very stable/ uniform(is there any better expression for this?) I wake up around 8am and study till noon. Except for lunch, dinner and brief breaks, I try to focus on studying. It's not difficult with help of challengers application and time recording application. Since it's winter time now, It's perfect to stay in and focus on studying. I hope I can enjoy outdoor activities and socialising by this summer!

profile
Dayeon Lee | Django & Python Web Developer

0개의 댓글