Automatically translated.View original post

How is the framework different from the Library???

# Web Site Writing Basics # Pythonprogramming # frameworks # Library

The difference between a Library (library) and a Framework is one of the most confusing programs, because they are both "ready-made code that others have written for us," but the most important difference is "Inversion of Control." To see the most obvious difference, let's see the main difference: 1. The Analogy Library is like a "toolbox" or "furniture": you build your own house (write down the main structure), and you walk to pick up a net, pliers, or buy a finished sofa in your house. You control when you use it and where you put it. The framework is like a "prefabricated house" or a "flange structure": he makes the frame of the house, breaks through the portholes, sets the water pipe system up. You have to just decorate, paint, or add in the box he has left. You can't move the main pillar of the house as you like because it's attached to a large structure. 2. Who calls? (Inversion of Control) This is the technical intersection that clearly separates these two things. Library (We run the code): Our main code controls the game. Whenever you want a special function, call the Library to work. When you finish, the power comes back to our code. Framework: The Framework controls the game. It has its own structure and lifecycle. It tells us, "If you want the web to display a new page, put the code in this file," and the Framework will pick up our code to run it itself. 3. The table summarizes the differences of the Library (Library) Framework (Framework) Control (Control) We control: Choose when to use it. The Framework controls: Forcing us to write according to its rules and structure. The size and scope are usually small. The focus solves specific problems (such as compute, graph), large, covers the entire architecture of the system. The freedom to write code is very high. The file or write any style is low. The file must be placed and named as specified. Otherwise, the system will crash samples in PythonNumPy, Pandas, Requests, mathDjango, Flask, FastAPI4. Based on the example of real code using the Library (such as requests to retrieve web data), you can see that we are writing the first line of code continuously. When you want web data, you can call requests. Get (). One command ends Python # Our code is big.

Print ("Start working")

Import request

Response = request.get ("https://api.github.com") # Run the library at will.

Print (respond.status _ code)

Print ("End of work")

Using the Framework (such as Flask to create a website), you do not order the program to start from top to bottom normally, but you must create a function based on the Framework rules and leave the Framework as the manager to open the Server and run our function when someone accesses Pythonfrom flask import Flask.

app = Flask (_ _ name _ _)

# We must write the code under the Route that the Framework defines

@ app.route ("/")

DEF home ():

"Hello, this is the front page."

♪ The Framework will run the whole system itself

if _ _ name _ _ = = "_ _ main _ _":

app.run ()

Brief summary: If you need a tool to do some work from time to time = use the Library, but if you need a finished structure to build a large system and follow its rules = use the Framework, sir.

5/17 Edited to

... Read moreจากประสบการณ์ที่ได้ลองใช้งานทั้ง Framework และ Library ในการพัฒนาโปรเจกต์ส่วนตัวมาแล้ว ผมพบว่าสิ่งที่ชัดเจนที่สุดคือเรื่องของการควบคุมโค้ดและความยืดหยุ่นเวลาพัฒนา Library นั้นเหมาะมากสำหรับงานที่เราต้องการเรียกใช้ฟังก์ชันเฉพาะเจาะจง เช่น การคำนวณทางคณิตศาสตร์ หรือการจัดการข้อมูล เช่น การใช้ NumPy หรือ Pandas ที่ช่วยให้โค้ดดีขึ้นแต่เรายังคงเป็นคนควบคุมลำดับการทำงานหลักในโปรแกรมทั้งหมด ในขณะเดียวกัน Framework อย่างเช่น Flask หรือ Django จะกำหนดรูปแบบโครงสร้างของโปรเจกต์และลำดับการทำงานมากกว่า ทำให้เราไม่ต้องเสียเวลาคิดโครงสร้างใหญ่ ทำให้การสร้างเว็บแอปพลิเคชันหรือระบบขนาดใหญ่รวดเร็วขึ้น แต่ก็จำเป็นต้องทำตามกฎและวิธีวางไฟล์ให้ถูกต้อง ซึ่งถ้าผิดพลาดอาจทำให้ระบบไม่ทำงานได้ นอกจากนี้คำว่า "Inversion of Control" ที่กล่าวถึงในบทความนี้ ผมเข้าใจว่าเป็นประเด็นสำคัญที่แบ่งแยกข้อแตกต่างระหว่าง Library และ Framework ได้ดีที่สุด สำหรับผู้เริ่มต้น ผมแนะนำให้ลองใช้ Library ในงานเล็ก ๆ เพื่อเข้าใจหลักการก่อน แล้วค่อยขยับไปใช้ Framework เมื่อเริ่มสร้างระบบใหญ่ขึ้น เพราะ Framework จะช่วยจัดการเรื่องซับซ้อนให้เราได้มาก ท้ายที่สุด การเลือกใช้ระหว่าง Framework กับ Library ควรขึ้นอยู่กับขนาดและลักษณะของโปรเจกต์ รวมถึงความต้องการควบคุมโค้ดของเราด้วย

Related posts

An overhead shot shows two cameras, an invoice screen displaying $110,364.88 in paid invoices, and the text 'HOW TO MONETIZE YOUR CONTENT'. This image illustrates the financial success discussed in the article.
A person holds a checkered cup in a home setting, with text overlays advising to 'START AT HOME' by proving capability without monetary incentive to build trust. It emphasizes that 'Your honest opinion MATTERS'.
A computer screen displays planning documents and calendars, with a hand holding a stylus. Text advises to 'PLAN YOUR POSTS', brainstorm with AI, and stick to a schedule, highlighting consistency for both algorithms and human brains.
HOW TO START MONETIZING YOUR CONTENT | Part I
I’m Chey, and I created a multimillion dollar company by the age of 32. I’m from Los Angeles California and I did not grow up in a privileged lifestyle in any way. At the age of 24 I was living out of my car, jumping from job to job, and felt completely hopeless for what tomorrow might brin
fromcheywithlove

fromcheywithlove

1918 likes

How to bring order to a chaotic brain
Do you find yourself forgetting things all the time and running back into the house to grab them? Because same! And sometimes it’s more than once. A scatter ADHD brain can be frustrating if it’s not controlled. There’s an easy fix for that.. and it doesn’t involve meds! Here are four hacks I
Jau 🤎 Growth Mentor

Jau 🤎 Growth Mentor

4055 likes

A handwritten October goal-setting framework on lined paper, outlining sections for Vision, One Domino, The One Things (Business, Personal, Health, Family), Execution (weekly focus, constraint), and Personal Board of Advisors (Strategy, Systems, Wealth, Health, Brand, Audience).
🎯 How to Crush Your October Goals
Don’t just set goals — build a system that guarantees them. Here’s a simple monthly planning framework I use to stay focused and consistent 👇 ✨ VISION Define your word, dream outcome, and how you want to feel by November 1st. 🔥 ONE DOMINO Choose the one system or habit that makes everyth
Steven Bou

Steven Bou

305 likes

A collection of various beauty products, including skincare, makeup, and fragrance items, presented as a PR haul, with text indicating it's about how to get PR.
A hand holding a box for a blemish-targeting gel, obtained through a specific collaboration platform mentioned as 'bzzagent'.
A hand holding a clear pink bag containing a set of body care products, received via a collaboration platform mentioned as 'skeepers'.
how to get luxury beauty pr from ur fav brands 😍🛍️
hey y’all it’s been a while cuz I’ve been in my bag! I never gatekeep, so swipe through and see the platforms I used to get pr! I also crafted a guide that shows you how to get started, pitching frameworks and more platforms!! any questions? Drop them below! Remember pr is great and free, but a
christelle 💕

christelle 💕

2835 likes

Free Finance Courses from MIT
Free Finance Courses from MIT If you are interested in Finance, these FREE courses from MIT make learning easy and accessible for everyone: 1. Foundations of Modern Finance I:It provides a rigorous and comprehensive introduction to the fundamentals of modern finance and their applications to
Ivy League Help

Ivy League Help

2106 likes

the 2 types of fatigue (& how to fix both!)
fatigue is so common, and it can be tricky to know how to deal with it ⤵️ sometimes you need to rest other times you need action just having the framework to differentiate between the two types of fatigue can go a long way in identifying and responding to your needs 🫶 💌 save this one for
carley ◡̈

carley ◡̈

217 likes

A vibrant poster on a stone wall with red roses illustrates Neville Goddard's 4-step manifestation guide: Feel It Real, Assume the State, Persist in the Assumption, and Accept It's Done. Each step includes text and a corresponding illustration, emphasizing living in the end and infusing desire with feeling.
How to Manifest with the Law of Assumption ✨
Ever feel like you’re doing everything “right” but your manifestations are still stuck in the mail? 💌 It’s time to stop trying and start being. 🕊️ According to Neville Goddard, the secret isn't in the wishing—it's in the feeling. This 4-step framework helps you shift from "wanting&#3
Mindset For Entrepreneurs

Mindset For Entrepreneurs

30 likes

NEW inside your library: Build Your Brand Guide In One Weekend ☕️ Does your brand feel... messy? Different fonts on your website, mixed messaging on social, colors that don't quite match your vibe? In a crowded market, "good enough" branding gets ignored. Memorable branding gets b
Summerana

Summerana

0 likes

A desk setup with a tablet displaying study material, an open textbook, and a notebook, with text overlay 'how to remember everything you study' and 'SWIPE FOR MORE'.
A digital note titled 'Teal's Notes' explaining the '80/20 rule' for studying, with examples for course material focus, time allocation, and feedback utilization.
A digital note titled 'Teal's Notes' detailing the 'Feynman Technique' as a learning framework, outlining steps like choosing a concept and teaching it to a child.
How to remember everything you study 💡
Unlocking the secrets of memory retention 🧠 I've added my favorite tips among the infographics that I shared, but I decided to add more tips on the caption that can also help you a lot. Dive into effective learning with these tips: 📚 Embrace active learning methods like teaching concept
teal.days

teal.days

6088 likes

A woman in a black dress reclines in a gondola on a canal in Venice, with the text 'Get Financial Freedom?' overlaid, introducing the topic of budgeting.
An infographic explaining the 50/30/20 budgeting rule with a pie chart, examples for a $20/hour income divided into Needs, Wants, and Savings jars, and a warning about credit card traps.
A list detailing specific examples for the 50/30/20 budgeting rule: Needs (food, bills, housing, transportation), Wants (shopping, dining out, entertainment, travel), and Savings (emergency fund, retirement, investments).
How To Budget Your Money Wisely 🍸
A budget is a plan for every dollar you have. It’s not magic, but it represents more financial freedom and a life with much less stress. Here’s how to set up and then manage your budget: First ~ Calculate your monthly income, pick a budgeting method and monitor your progress. Try the 50/30/20 ru
Angelina

Angelina

1081 likes

How I healed from past pain & trauma
disclaimer: I am by no means a mental health professional this is what has worked for me! I am simply sharing my experience. Please seek appropriate help if you need to. This is what has changed my life truly!!! Without these tools and learning these things, I would not be where I am today. My t
chels

chels

47 likes

how cafes can become “that spot” ☕️🫶
it’s always so cool to see places support locals and micro-influencers 🥹 #coffeeshop #microinfluencer #newjersey #coffeetips #socialmediagrowthtips
coco bear 🧸 | nj coffee girly

coco bear 🧸 | nj coffee girly

4 likes

my simple 2026 planning framework
Tell me I am not the only one who does this. I’ve been using this framework for the past couple of years for my annual planning and have enjoyed it! It goes like this: 1. Reflect first 2. Define your values 3. Choose 3 focuses for the year 4. Set specific measurable goals 5. Reflect on your
Apps with Anne

Apps with Anne

29 likes

How to Calibrate Your Relationship Compass as 1🤍🫶🥰
A "Relationship Compass" that points true north is a framework used to navigate the complexities of human connection by centering on core values rather than fleeting emotions or external pressures. When a compass points "True North," it isn't just following a magnetic pull; it i
Relationship Coach & Therapist

Relationship Coach & Therapist

2 likes

A desktop monitor displays a Notion assignments page, while a tablet shows a calendar. Overlay text reads "KICK OFF YOUR SEMESTER LIKE A PRO WITH AI (2024 EDITION)", highlighting productivity tools.
Screenshots demonstrate ChatGPT's capabilities, including generating research surveys, summarizing articles, and its limitation of not accessing private subscription-based websites.
Notion screenshots illustrate features like AI-generated key points, assignment tracking, a calendar view, and flexible note-taking for organizing academic materials.
How To Cheat Your Time 2x More Efficient With AI👩🏻‍💻⏱️
No matter how much we want to deny it, we are now officially living in a time with AI💡Instead of rejecting its existence, we should turn it into our best friend and navigate it to go through our busiest days💻 I’m currently a Senior in college WITH a Part-time job which I need to go 20hrs/week🥲I de
Ruoqiqi

Ruoqiqi

68 likes

A couple kisses outdoors, with the title overlay "10 Things I Do Differently as a Wife After Healing From Betrayal." The man wears a cap and shorts, the woman sunglasses and a tank top. A vehicle is in the background.
A couple kisses outdoors, with text overlay stating, "Before healing, I loved from fear... Healing didn't harden me... it softened me into clarity, safety, and devotion... Here's what changed..."
A couple kisses outdoors, with text overlay numbered '1' stating, "I no longer carry both roles... I let him embody his masculine... This comes from trust in who I am..."
10 things I do different after betrayal…
If you’re reading this…there’s a version of you that’s still fighting for air…Still trying to figure out how to love again without losing yourself…⁣ ⁣ Still trying to understand how to be a wife when your heart has been cracked open in ways you never asked for…⁣ ⁣ And I want to tell you somethi
Echo⚡️Consciousness

Echo⚡️Consciousness

251 likes

Beyond SMART: How I Set Goals as a Student
1. The 'HARD' Goals Method ❤️‍🔥 This framework is my go-to for big, ambitious life goals because it connects them to my emotions. Instead of being specific and measurable, a HARD goal has to be Heartfelt (it matters), Animated (I can picture achieving it and feel the excitement), Required
emilie.studygram

emilie.studygram

72 likes

A person takes a mirror selfie in a gym, with text overlay stating "YOUR GYM CHOICE CAN MAKE OR BREAK YOUR GAINZ" and arrows pointing to their glutes.
White text on a purple background discusses the importance of gym hygiene and safety, citing studies on bacteria on equipment and the risk of infections.
White text on a purple background explains how gym atmosphere, motivation, and psychology impact workout consistency and self-efficacy, with a Reddit anecdote.
How to MAXIMIZE Ur GAINZ by Choosing the RIGHT Gym
Ranking 10 Popular Gyms by What Really Matters We’ve all heard it: “It doesn’t matter what gym you go to, it’s about how you work out.” But after training in garage gyms, budget chains, bougie studios, and everything in between, I can confidently say: the gym you choose matters more than you thi
Chalie_Baker

Chalie_Baker

29 likes

Is Tyla a flop in the US?
I’ll discuss a a really interesting and sensitive part of the conversation around Tyla in the U.S. Some Black American fans have expressed that her self-identification as “colored” — a term with different historical and cultural meanings, especially in South Africa — might feel distancing or confus
EternalWomenInc

EternalWomenInc

59 likes

The first slide introduces a summer series titled "build with your kid - ep 01," encouraging viewers to save it for summer break to learn how to build an app with their child in one afternoon.
This slide, titled "the promise," states that an app can be built with a child in one afternoon, focusing on an idea they wish existed, without needing to code, just the right prompts.
The third slide outlines "the four steps" framework for building an app: 01 Idea (what they wish existed), 02 Validate (interrogate it), 03 Build (the ugly version first), and 04 Refine (the kid is the user-tester).
Build an App With Your Kid This Summer | The 4-Step Framework (No Code)
🪺 Save this for summer break — how to build an app with your kid in one afternoon. No code, no course, no $497 program. Just an afternoon and the right prompts. Who this is for: — Parents looking for screen time that isn’t passive — Homeschoolers building real-world skills with their kids — Tea
Unexpected nest

Unexpected nest

2 likes

Clean time For the home:
Cleaning your whole house with plant-based and budget-friendly products can be effective and safe. Below are some suggestions for supplies you can purchase at Dollar Tree, DIY alternatives, and instructions on how to clean various areas in your home, including a homemade bed spray. ### Suggeste
Purple Flower

Purple Flower

40 likes

Five-Month Success Framework This framework breaks down the journey into key monthly focu
Five-Month Success Framework This framework breaks down the journey into key monthly focuses: Month 1: Self-Assessment Conduct a brutally honest self-assessment of your strengths, weaknesses, and existing habits. Identify what truths about yourself are holding you back. Month 2: Goal Settin
Mindset Hustle TV ™

Mindset Hustle TV ™

4 likes

How To Avoid Burnout!
Burnout is quietly destroying the focus, health, and leadership potential of high performers everywhere, but it doesn’t have to. In this powerful episode of the Vertical Momentum Resiliency Podcast, TEDx speaker, bestselling author, and leadership expert Bianca Best shares how ambitious entrepre
Veterans Supporting Veterans

Veterans Supporting Veterans

1 like

A view inside a library, showing a staircase with white railings and wooden handrails, leading up, with bookshelves visible in the background. Text overlay reads 'The Fine Arts Library'.
A collage showing a library room with tables, bookshelves, and a hand operating a circuit breaker panel, illustrating the task of turning on lights and checking upstairs.
A hand placing a light green lunch container and two juice bottles into a white refrigerator, with the text overlay 'Put lunch away'.
Day as a Part-Time Student Library Worker
This was a different type of post for me but I wanted to show a day in my life as a part time worker at one of the smaller libraries on my campus📚📖 I worked 9-1 today and wanted to show you some of the things I get done during my slower shifts😊 I love working at my school library because it is su
Gaby Perez

Gaby Perez

12 likes

Five-Month Success Framework This framework breaks down the journey into key monthly focu
Five-Month Success Framework This framework breaks down the journey into key monthly focuses:  Month 1: Self-Assessment Conduct a brutally honest self-assessment of your strengths, weaknesses, and existing habits.  Identify what truths about yourself are holding you back.  Month 2: G
Mindset Hustle TV ™

Mindset Hustle TV ™

6 likes

A person in a grey suit and black shirt holds a dark red bag, with overlay text "How TO ELEVATE YOUR LOOK STYLING TIPS" on a dark background.
This image details "PERFECT YOUR FIT" and "ADD STRUCTURED PIECES" with text tips and three models showcasing structured outfits like suits and coats.
This image covers "EMBRACE MONOCHROME" and "INVEST IN BASICS" with text advice and models wearing single-color outfits and basic apparel.
How to Elevate Your Style
Hi guys! Here are 7 simple steps to elevate your style effortlessly! From perfecting your fit to mastering monochrome, these tips will help you look polished and chic every day. ✨Want to go deeper? I created a full digital guide that walks you through my effortless style framework. Check out 🔗i
AUDREY 🍒

AUDREY 🍒

173 likes

How to generate a logo with AI
Start to finish — brief, prompt, tools, iteration 🪺 Most AI logos look generic because the prompts have no direction. Here's the full process for getting something that actually works — from deciding what you want to directing the AI like an art director. ⌁ 🪺 Step 1: Three decisions be
Unexpected nest

Unexpected nest

4 likes

See more