<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mayowa-kalejaiye</title>
    <description>The latest articles on DEV Community by mayowa-kalejaiye (@mayowakalejaiye).</description>
    <link>https://dev.to/mayowakalejaiye</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1671362%2F0d6850d7-b9ca-48c1-ab0b-f6173df4f36a.jpeg</url>
      <title>DEV Community: mayowa-kalejaiye</title>
      <link>https://dev.to/mayowakalejaiye</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mayowakalejaiye"/>
    <language>en</language>
    <item>
      <title>Deploying My Flask API: From Debugging Nightmares to a Live Service - HNG STAGE1 TASK</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Fri, 07 Feb 2025 13:53:57 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/deploying-my-flask-api-from-debugging-nightmares-to-a-live-service-hng-stage1-task-2hac</link>
      <guid>https://dev.to/mayowakalejaiye/deploying-my-flask-api-from-debugging-nightmares-to-a-live-service-hng-stage1-task-2hac</guid>
      <description>&lt;p&gt;I recently built a Number Classification API as directed in my task, Take a number, classify it as prime, perfect, Armstrong, odd/even, and return a fun fact.&lt;/p&gt;

&lt;p&gt;Building it? Smooth.&lt;br&gt;
Deploying it? A different battle entirely.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Initial Plan
&lt;/h3&gt;

&lt;p&gt;I used Flask for the backend and hosted it on Render (because free tier 😅). Everything was working locally, so I confidently pushed my code and waited for a smooth deployment.&lt;/p&gt;

&lt;p&gt;But then...&lt;/p&gt;

&lt;p&gt;The Unexpected Errors&lt;br&gt;
The moment my API hit the deployment phase, errors started flying in:&lt;/p&gt;

&lt;p&gt;❌ "py: command not found" – Apparently, Render’s environment doesn’t recognize py, so python it is.&lt;/p&gt;

&lt;p&gt;❌ "No open ports detected" – Flask was binding to 127.0.0.1 instead of 0.0.0.0, which doesn’t work on a server. Rookie mistake, I’ll own it.&lt;/p&gt;

&lt;p&gt;❌ "Your service is live!" (but only locally 😭) – My API was running, but only inside the container, unreachable from the outside world.&lt;/p&gt;

&lt;p&gt;At this point, I knew I had two choices: rage-quit or debug. Debugging won.&lt;/p&gt;

&lt;p&gt;The Fixes&lt;br&gt;
Here’s how I got everything working:&lt;/p&gt;

&lt;p&gt;✅ Explicitly set the port: app.run(host='0.0.0.0', port=int(os.environ.get("PORT", 5000)))&lt;br&gt;
✅ Updated my requirements.txt: A missing dependency was causing silent failures.&lt;br&gt;
✅ Switched to Gunicorn for production: Flask’s built-in dev server isn’t meant for deployment.&lt;/p&gt;

&lt;p&gt;After testing, tweaking, and a few deep sighs, I finally saw:&lt;br&gt;
🎉 "Your service is live!"&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lessons Learned&lt;/em&gt;&lt;br&gt;
Deployment will always test you—be ready to debug.&lt;br&gt;
Never assume local setups = production setups.&lt;br&gt;
Error messages are clues, not enemies.&lt;br&gt;
Now that my API is up, time to build something even bigger. 🚀&lt;/p&gt;

&lt;p&gt;Have you ever had an unexpected deployment struggle? Drop a comment—I’d love to hear your war stories!&lt;/p&gt;

&lt;h1&gt;
  
  
  Flask #Python #API #Debugging #Deployment #SoftwareEngineering #HNG
&lt;/h1&gt;

</description>
      <category>hng</category>
      <category>backend</category>
      <category>api</category>
      <category>python</category>
    </item>
    <item>
      <title>Built public API for HNG stage0 task</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Fri, 31 Jan 2025 14:58:35 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/built-public-api-for-hng-stage0-task-3aa8</link>
      <guid>https://dev.to/mayowakalejaiye/built-public-api-for-hng-stage0-task-3aa8</guid>
      <description>&lt;p&gt;dev.to Post:&lt;br&gt;
I’ve just wrapped up building a simple public API for HNG Stage 0, and wanted to share a bit about the process!&lt;/p&gt;

&lt;p&gt;Even though I’ve worked with APIs before and deployed apps on Render multiple times, this was still a solid exercise in polishing up those skills. The task was straightforward but required attention to detail, especially around CORS configuration, which I had to tweak a bit. But, that's the fun of development, right?&lt;/p&gt;

&lt;p&gt;The API serves the following:&lt;/p&gt;

&lt;p&gt;My email&lt;br&gt;
The current UTC datetime in ISO format&lt;br&gt;
A GitHub URL of the repository&lt;br&gt;
I used FastAPI and Python to build the backend. Render took care of the deployment, and it was a breeze to get everything up and running.&lt;/p&gt;

&lt;p&gt;💡 Key lessons:&lt;/p&gt;

&lt;p&gt;Don't underestimate how simple things (like configuring CORS) can trip you up.&lt;br&gt;
The deployment process isn’t always as smooth as it seems, but the satisfaction of seeing everything work is worth it.&lt;br&gt;
Check out my API here: &lt;a href="https://hng-stage0-task-ewk2.onrender.com/" rel="noopener noreferrer"&gt;https://hng-stage0-task-ewk2.onrender.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re someone who's been through a similar process, you know how fulfilling it can be to get everything live. 🙌&lt;/p&gt;

&lt;h1&gt;
  
  
  Python #FastAPI #API #BackendDevelopment #Deployment #TechJourney #WebDev
&lt;/h1&gt;

</description>
      <category>hng</category>
      <category>fastapi</category>
      <category>api</category>
      <category>python</category>
    </item>
    <item>
      <title>Updated Day 5 Post: State Management in React - Mastering useState and Beyond! 🚀</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Sat, 28 Dec 2024 18:52:54 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/day-5-state-management-in-react-mastering-usestate-and-beyond-58o0</link>
      <guid>https://dev.to/mayowakalejaiye/day-5-state-management-in-react-mastering-usestate-and-beyond-58o0</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hey Dev Community!&lt;/strong&gt; 👋&lt;/p&gt;

&lt;p&gt;Today was all about state management in React, and I’m excited to share what I learned. State is the heart of dynamic React apps, and mastering it opens up a world of possibilities. Here’s the breakdown:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. useState: The Foundation of State Management
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;useState&lt;/code&gt; is the simplest way to add state to functional components. Here’s how it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click Me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🚨 Improvement Alert!
&lt;/h3&gt;

&lt;p&gt;As pointed out by a community member, state updates are asynchronous. If you have multiple updates in quick succession, using setCount(count + 1) can lead to bugs because it might use an outdated value.&lt;/p&gt;

&lt;p&gt;Instead, use the functional form to ensure you’re always working with the latest state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevCount&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;prevCount&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click Me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✨ Why It’s Better:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Guarantees the most recent state value.&lt;/li&gt;
&lt;li&gt;Prevents bugs in complex scenarios with multiple updates.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Lifting State Up
&lt;/h3&gt;

&lt;p&gt;When multiple components need to share state, you can &lt;strong&gt;lift state up&lt;/strong&gt; to their closest common ancestor. This keeps your app’s data flow predictable and organized.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Beyond useState: useReducer
&lt;/h3&gt;

&lt;p&gt;For more complex state logic, &lt;code&gt;useReducer&lt;/code&gt; is a game-changer. It’s like &lt;code&gt;useState&lt;/code&gt; on steroids:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;initialState&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;  

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;reducer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
  &lt;span class="k"&gt;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;increment&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;  
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;decrement&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;  
    &lt;span class="nl"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;  
  &lt;span class="p"&gt;}&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useReducer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;reducer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;initialState&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✨ Why It’s Awesome:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Great for managing complex state transitions.&lt;/li&gt;
&lt;li&gt;Makes state logic easier to test and debug.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4. State Management Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Keep State Local&lt;/strong&gt;: Only lift state up when necessary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid Overusing State&lt;/strong&gt;: Use derived state or props when possible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use Context for Global State&lt;/strong&gt;: For app-wide state, React Context is your friend (more on this later!).&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  What’s Next?
&lt;/h3&gt;

&lt;p&gt;In the coming days, I’ll dive into &lt;strong&gt;React Context&lt;/strong&gt; and &lt;strong&gt;state management libraries&lt;/strong&gt; like Redux. Stay tuned!&lt;/p&gt;




&lt;h3&gt;
  
  
  Closing Thoughts
&lt;/h3&gt;

&lt;p&gt;State management is what makes React apps dynamic and interactive. Whether it’s a simple counter or a complex app, mastering state is key to building powerful UIs. And thanks to the community, I’ve learned an important best practice: always use the functional form for state updates!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next up: React Context!&lt;/strong&gt;&lt;br&gt;
If you’re learning React too, let’s connect and grow together! 🚀&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Customizing React Components with Props 🚀</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Thu, 26 Dec 2024 19:27:10 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/day-3-customizing-react-components-with-props-3of9</link>
      <guid>https://dev.to/mayowakalejaiye/day-3-customizing-react-components-with-props-3of9</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hey Dev Community&lt;/strong&gt;! 👋&lt;/p&gt;

&lt;p&gt;Today was an exciting day in my React journey as I dove deep into the world of &lt;strong&gt;props&lt;/strong&gt; and learned how to create dynamic and reusable components. Here's a quick rundown of what I accomplished and what I learned through Day 3/4:&lt;/p&gt;

&lt;h3&gt;
  
  
  What I Did Today:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Set Up a New React Project&lt;/strong&gt;🛠️&lt;br&gt;
 I started by creating a fresh React project using &lt;code&gt;Create React App&lt;/code&gt;. I cleared out the boilerplate code to set up a &lt;strong&gt;clean slate&lt;/strong&gt; for my custom components.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Created Custom Components&lt;/strong&gt;🧩&lt;br&gt;
I built a custom &lt;code&gt;AnimalCard&lt;/code&gt; component to display information about animals. This component is designed to be &lt;strong&gt;reusable&lt;/strong&gt; and &lt;strong&gt;dynamic&lt;/strong&gt;, meaning it can display different data based on the props it receives.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Passed Props to Components&lt;/strong&gt;📤&lt;br&gt;
I learned how to pass data from a parent component (&lt;code&gt;App&lt;/code&gt;) to a child component (&lt;code&gt;AnimalCard&lt;/code&gt;) using props. Props can be &lt;strong&gt;anything&lt;/strong&gt;: strings, numbers, arrays, objects, or even functions! For example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AnimalCard&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Lion"&lt;/span&gt;
  &lt;span class="na"&gt;scientificName&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Panthera leo"&lt;/span&gt;
  &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;140&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;diet&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;meat&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rendered Lists of Data&lt;/strong&gt;&lt;br&gt;
I used the &lt;code&gt;.map()&lt;/code&gt; method to loop through an array of animal data and rendered a list of &lt;code&gt;AnimalCard&lt;/code&gt; components. This made it super easy to display &lt;strong&gt;multiple animals dynamically&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Added PropTypes for Validation&lt;/strong&gt;&lt;br&gt;
To make my components more &lt;strong&gt;predictable&lt;/strong&gt; and &lt;strong&gt;bug-free&lt;/strong&gt;, I added &lt;strong&gt;PropTypes&lt;/strong&gt; to define the expected data types for each prop. For example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;AnimalCard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;propTypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PropTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isRequired&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
  &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PropTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isRequired&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
  &lt;span class="na"&gt;diet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PropTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;arrayOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PropTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;isRequired&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Set Default Props&lt;/strong&gt; ⚙️
I also learned how to set &lt;strong&gt;default values&lt;/strong&gt; for props using &lt;code&gt;defaultProps&lt;/code&gt;. This ensures that my component doesn’t break if a prop is missing. For example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;AnimalCard&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;defaultProps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
  &lt;span class="na"&gt;additional&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;No Additional Information&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;  
&lt;span class="p"&gt;};&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Styled the Components 🎨&lt;/strong&gt;
I added some basic CSS to make the &lt;strong&gt;AnimalCard&lt;/strong&gt; components look &lt;strong&gt;clean&lt;/strong&gt; and &lt;strong&gt;organized&lt;/strong&gt;. Flexbox came in handy for aligning the cards neatly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Key Takeaways:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Props are Powerful&lt;/strong&gt; 💪: Props allow you to create &lt;strong&gt;flexible&lt;/strong&gt; and &lt;strong&gt;reusable&lt;/strong&gt; components. You can pass any type of data to a component, making it highly adaptable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;PropTypes are Essential&lt;/strong&gt; 🔍: Using PropTypes helps catch errors early and makes your components more &lt;strong&gt;predictable&lt;/strong&gt;. It’s like adding a &lt;strong&gt;safety net&lt;/strong&gt; for your data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Default Props are Lifesavers&lt;/strong&gt; 🆘: Setting default values for props ensures your component won’t break if some data is missing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dynamic Rendering is Awesome&lt;/strong&gt; ✨: Using &lt;code&gt;.map()&lt;/code&gt; to render lists of components is a &lt;strong&gt;game-changer&lt;/strong&gt;. It makes it easy to display large datasets without writing repetitive code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What’s Next?
&lt;/h3&gt;

&lt;p&gt;Tomorrow, I’m planning to explore &lt;strong&gt;state management&lt;/strong&gt; in React and learn how to make my components more &lt;strong&gt;interactive&lt;/strong&gt;. I’m also curious about &lt;strong&gt;React Hooks&lt;/strong&gt; and how they can simplify my code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts:
&lt;/h3&gt;

&lt;p&gt;Today was a &lt;strong&gt;big step forward&lt;/strong&gt; in my React journey. I feel more confident in creating and customizing components, and I’m excited to keep building on this foundation. If you’re just starting out with React, I highly recommend diving into &lt;strong&gt;props&lt;/strong&gt; and &lt;strong&gt;PropTypes&lt;/strong&gt;—they’re fundamental to building &lt;strong&gt;scalable&lt;/strong&gt; and &lt;strong&gt;maintainable&lt;/strong&gt; applications.&lt;/p&gt;

&lt;p&gt;Let me know if you have any tips or resources for learning &lt;strong&gt;state&lt;/strong&gt; and &lt;strong&gt;hooks&lt;/strong&gt;! I’d love to hear your thoughts. 😊&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;#React #JavaScript #WebDevelopment #LearnToCode #Day3&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Feel free to share your feedback or ask questions in the comments! Let’s keep learning together. 🚀&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>React Clicks, Styles, &amp; Conditionals! 🎨💥</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Tue, 24 Dec 2024 19:27:53 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/react-clicks-styles-conditionals-16h8</link>
      <guid>https://dev.to/mayowakalejaiye/react-clicks-styles-conditionals-16h8</guid>
      <description>&lt;p&gt;&lt;strong&gt;🎉 Hello React Enthusiasts! 🎉&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Welcome back to Day 2 of my React journey! Today, we’ve officially moved from the basics to the good stuff—we're talking click events, styling, and conditional rendering. 🖱️✨&lt;/p&gt;

&lt;p&gt;You know, the magic ingredients that turn a static page into a dynamic, interactive app that feels... well, alive. Let’s dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Outline: Building an Interactive React App (The Fun Stuff)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1️⃣ Adding Markup: Setting the Stage
&lt;/h3&gt;

&lt;p&gt;Before we add all that juicy interactivity, we need a little structure. Here’s our humble beginning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Welcome to React Reloaded! 🚀&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Day 2: Clicks, Style, and Conditionals. Let’s make things happen!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;“Simple, right? But hold on, things are about to get spicy!” 🔥&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2️⃣ Styling: Bringing it to Life 🌈
&lt;/h3&gt;

&lt;p&gt;Ever tried adding style to a button and felt like a wizard casting spells? 💫 No? Well, it's time to learn!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💥 Inline Styling&lt;/strong&gt;&lt;br&gt;
Get up close and personal with your buttons with inline styles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buttonStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;purple&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;10px 20px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;none&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;borderRadius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;5px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pointer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;StyledButton&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;buttonStyle&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click Me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The button’s got attitude now, don’t you think? 😎&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💥 External CSS (The Pro Approach)&lt;/strong&gt;&lt;br&gt;
Let’s take it up a notch and move the style to a separate CSS file. Why? Because we like to keep things clean. 💼&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* styles.css */&lt;/span&gt;
&lt;span class="nc"&gt;.btn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;teal&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we’re talking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./styles.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;StyledButton&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"btn"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click Me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3️⃣ Click Events: Interactivity Unlocked 🎉
&lt;/h3&gt;

&lt;p&gt;Now here comes the fun part: &lt;strong&gt;Click Events!&lt;/strong&gt; Time to make things move and groove. 😜&lt;/p&gt;

&lt;p&gt;Here’s a little counter button, because... who doesn't love clicking things?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ClickHandler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;You clicked &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; times! 🚀&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click Me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click it—watch the magic happen. You’re basically a magician at this point. 🎩✨&lt;/p&gt;

&lt;h3&gt;
  
  
  4️⃣ Mapping Data: Efficiency Meets Elegance 🏆
&lt;/h3&gt;

&lt;p&gt;If you’ve got a list, why not map it to the screen? 🖥️ It’s faster than your favorite pizza delivery.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;React&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;JavaScript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CSS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ItemList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No more boring loops—just elegant, dynamic rendering. 😎&lt;/p&gt;

&lt;h3&gt;
  
  
  5️⃣ Conditional Rendering: Dynamic Displays 🎭
&lt;/h3&gt;

&lt;p&gt;Sometimes your app needs to think. Is the user logged in? Or not? 🤔 We’re about to make your app smart:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ConditionalRendering&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsLoggedIn&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Welcome back, User! 🎉&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Please log in to continue. 😢&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setIsLoggedIn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isLoggedIn&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Log Out&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Log In&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s like a little emotional rollercoaster for your users. 😜&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ Why These Features Matter (In Case You Haven't Noticed)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Styling &amp;amp; Events: Transform your app from meh to wow in seconds.&lt;/li&gt;
&lt;li&gt;Conditional Rendering: Makes your app feel like it knows what’s going on. It’s like the app has mood swings... but in a good way.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🎉 And That’s a Wrap for Day 2! 🏁&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We’ve officially touched on click events, styling, and conditional rendering. These are the building blocks of your next interactive web app, so get ready to show off your skills! 💪&lt;/p&gt;

&lt;h3&gt;
  
  
  What’s Next? 👀
&lt;/h3&gt;

&lt;p&gt;In &lt;strong&gt;Day 3&lt;/strong&gt;, we’re going deeper into state management and hooks. Trust me, things are about to get even more exciting! 🔥&lt;/p&gt;

&lt;p&gt;💬 What do you think about these features? Drop your thoughts, questions, or random React jokes in the comments—I’m all ears! 🎧&lt;/p&gt;

</description>
      <category>programming</category>
      <category>react</category>
      <category>webdev</category>
      <category>learninginpublic</category>
    </item>
    <item>
      <title>React &amp; Me: Day 1 Shenanigans 😎</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Mon, 23 Dec 2024 23:30:43 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/react-me-day-1-shenanigans-37fl</link>
      <guid>https://dev.to/mayowakalejaiye/react-me-day-1-shenanigans-37fl</guid>
      <description>&lt;p&gt;🚨 &lt;strong&gt;Breaking News&lt;/strong&gt;: JSX and I are officially besties now! 💻&lt;br&gt;
Spent my day getting reacquainted with how files in React love to work together. It’s like building a puzzle where every piece fits perfectly—if you don’t misplace your &lt;code&gt;import&lt;/code&gt; statements. 😅&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Achievement Unlocked&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSX expressions got me feeling like I’m writing magic spells 🪄.&lt;/li&gt;
&lt;li&gt;Component synergy = 💯.&lt;/li&gt;
&lt;li&gt;Here’s to more React adventures and fewer bugs (hopefully)! 🐛✨&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;P.S.: If you love React or just debugging chaos, hit me up in the comments. Let’s vibe! 🤙&lt;/p&gt;

</description>
      <category>programming</category>
      <category>discuss</category>
      <category>learninginpublic</category>
      <category>reactjsdevelopment</category>
    </item>
    <item>
      <title>React Reloaded: My Journey from JSX to Component Synergy 🚀</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Mon, 23 Dec 2024 23:17:02 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/react-reloaded-my-journey-from-jsx-to-component-synergy-52k6</link>
      <guid>https://dev.to/mayowakalejaiye/react-reloaded-my-journey-from-jsx-to-component-synergy-52k6</guid>
      <description>&lt;h2&gt;
  
  
  Day 1: Relearning React Basics 🌟
&lt;/h2&gt;

&lt;p&gt;Today marked the first step in my React relearning journey, and wow, what an adventure into the basics! Here’s what I tackled:&lt;/p&gt;




&lt;h2&gt;
  
  
  1️⃣ JSX - JavaScript's Magical Companion 🎩
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;JSX&lt;/strong&gt; (JavaScript XML) is like the hybrid language of HTML and JavaScript. Here's why it's so powerful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Looks Like HTML but packs the punch of JavaScript under the hood.&lt;/li&gt;
&lt;li&gt;Dynamic Rendering: You can embed JavaScript expressions directly into your UI. For instance:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, React!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;🚀 With JSX, your app can dynamically adapt to data changes!&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2️⃣ File Structure: Pieces of a React Puzzle 🧩
&lt;/h2&gt;

&lt;p&gt;Understanding how files work together was another major checkpoint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;index.js&lt;/strong&gt;: The gateway. It renders everything onto the DOM using ReactDOM.render().&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App.js&lt;/strong&gt;: The powerhouse! It’s where your components come together to create magic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Component File&lt;/strong&gt;s: These are the building blocks that make your UI modular and reusable.
Here’s an example of a basic component setup:
&lt;strong&gt;App.js&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Header&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Header&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;  
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;  
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Header&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;  
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Welcome to my React Journey!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;  
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;  
  &lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Header.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;React Reloaded 🌟&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;  

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Header&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;💡 Each file has its purpose, making code organized and easy to debug!&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3️⃣ Why These Basics Matter 🧠
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JSX simplifies development by merging UI and logic seamlessly.&lt;/li&gt;
&lt;li&gt;File Structure keeps the code modular, reusable, and scalable.&lt;/li&gt;
&lt;li&gt;These foundational concepts make React such a powerful library for building interactive and dynamic user interfaces.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Closing Thoughts&lt;/strong&gt;&lt;br&gt;
This is just the start! With React, even the basics are a strong foundation for building jaw-dropping applications. Can't wait to dive deeper and tackle hooks, state management, and more.&lt;/p&gt;

&lt;p&gt;Let’s keep the momentum going! 🚀&lt;br&gt;
If you’re relearning React too, drop a comment below. Let's grow together!&lt;/p&gt;

</description>
      <category>learninpublic</category>
      <category>react</category>
      <category>webdev</category>
      <category>codingjourney</category>
    </item>
    <item>
      <title>🌈 The Emotional Rollercoaster of My First Deployed Django Project - Moodify 🌈-my day 6 of the challenge</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Fri, 18 Oct 2024 13:04:31 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/the-emotional-rollercoaster-of-my-first-deployed-django-project-moodify-my-day-6-of-the-challenge-2ch</link>
      <guid>https://dev.to/mayowakalejaiye/the-emotional-rollercoaster-of-my-first-deployed-django-project-moodify-my-day-6-of-the-challenge-2ch</guid>
      <description>&lt;p&gt;&lt;strong&gt;There I was. A wild-eyed dreamer with a laptop and a thousand lines of code.&lt;/strong&gt; 🤯 What started as just another idea morphed into something I never saw coming—my first deployed Django project, live and running for the world to see! &lt;em&gt;Moodify&lt;/em&gt;, my beloved brainchild, is now at &lt;a href="https://moodify-wmcd.onrender.com" rel="noopener noreferrer"&gt;moodify-wmcd.onrender.com&lt;/a&gt;, and its code, every line and sweat-soaked keystroke, lives on GitHub: &lt;a href="https://github.com/mayowa-kalejaiye/Moodify.git" rel="noopener noreferrer"&gt;check out the repo&lt;/a&gt;. But this wasn’t some ordinary project. It was an adventure filled with all the highs, lows, breakthroughs, and breakdowns of being a dev.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌱 The Beginning: A Blank Page and Endless Possibilities
&lt;/h2&gt;

&lt;p&gt;Like most projects, this one started with an idea. &lt;em&gt;How do I help people track their mood and mental well-being?&lt;/em&gt; I had no clue how challenging it was going to be. But I dived in, full of enthusiasm, armed with Django, and a million tabs on Google.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Early Lessons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unlearning Simplicity&lt;/strong&gt;: I thought creating a simple mood tracker would be a breeze. Oh boy, was I wrong. Suddenly, I was deep into forms, models, views, and before I knew it, I was wrestling with the beast that is Django's ORM.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learning the Art of Patience&lt;/strong&gt;: There were days where I was so close to just tossing my laptop across the room. From figuring out database migrations to managing environment variables, I came to realize patience is not just a virtue; it's a survival skill.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🔥 The Struggles: Debugging, Crying, and Almost Giving Up
&lt;/h2&gt;

&lt;p&gt;Oh yes, I faced it all. The “&lt;strong&gt;Why isn't this working?!&lt;/strong&gt;” moments that stretched on for hours (or was it days? 🫠). The days I convinced myself I’d give up and switch careers—become a farmer or something easier.-just kidding😂&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Moment I Thought I Was Done&lt;/strong&gt;&lt;br&gt;
There was this one bug. Oh man. It was right there, mocking me. The &lt;strong&gt;ALLOWED_HOSTS&lt;/strong&gt; issue—it seemed harmless at first, but it haunted me! Why wouldn’t my app deploy? Why were hosts like &lt;code&gt;127.0.0.1&lt;/code&gt; messing with my life?&lt;/p&gt;

&lt;p&gt;And just when I was about to hit CTRL + Q on the whole thing, I discovered the magic of environmental variables and &lt;code&gt;.env&lt;/code&gt; files. A tiny fix, a huge relief. &lt;em&gt;Note to self: always trust the environment.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Debugging teaches you resilience&lt;/strong&gt;. When I couldn’t log in to the admin dashboard after a minor glitch? I had to laugh. Turns out, I’d somehow wiped the admin user. Creating a new one, though annoying, felt like a fresh start.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  💡 What I Learned: Big Wins and Exciting Discoveries
&lt;/h2&gt;

&lt;p&gt;Despite the tears, this project was a learning goldmine.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Environment Variables Are Your Friend&lt;/strong&gt;: Hiding my &lt;code&gt;SECRET_KEY&lt;/code&gt; in &lt;code&gt;.env&lt;/code&gt; and managing &lt;code&gt;DEBUG&lt;/code&gt; mode taught me a lot about the importance of security in web apps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database Management with Django&lt;/strong&gt;: From creating and updating models to handling migrations, I now know more about databases than I thought possible. And trust me, I’ve broken enough tables to prove it!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deploying to Production&lt;/strong&gt;: Let's talk about the moment of truth—deployment. You see, I thought deployment was going to be a piece of cake. But when &lt;strong&gt;Render&lt;/strong&gt; started throwing errors at me, that’s when the real show began. After tweaking static file configurations and sorting out SSL issues, I finally got it up and running. I literally screamed, "It's ALIVE!"(so many times 🫠)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But the most &lt;em&gt;beautiful&lt;/em&gt; part? Finally hitting the URL &lt;a href="https://moodify-wmcd.onrender.com" rel="noopener noreferrer"&gt;moodify-wmcd.onrender.com&lt;/a&gt; and seeing it work. Just &lt;em&gt;chef’s&lt;/em&gt; kiss. 😍&lt;/p&gt;

&lt;h2&gt;
  
  
  🎢 The Emotional Rollercoaster: The Ups, the Downs, and the Feels
&lt;/h2&gt;

&lt;p&gt;There were days when I felt on top of the world. When the login system worked flawlessly or when the styling clicked into place, I felt invincible.&lt;/p&gt;

&lt;p&gt;And then there were days where the code fought back. Days where I wanted to give up entirely. I’m looking at you, “CSRF token missing or incorrect.” 😩&lt;/p&gt;

&lt;p&gt;But those little wins—the times the app functioned just as I wanted—those were the moments that made it all worth it. The first time I logged a mood and it appeared in the database? Pure joy. The small dopamine hits from overcoming obstacles kept me going.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 The Final Stretch: The Joy of Deployment
&lt;/h2&gt;

&lt;p&gt;The final sprint toward deployment was wild. I’d never deployed a Django app before, and honestly, the idea scared me. But it was time to face my fears. I learned to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Configure environment variables&lt;/strong&gt; to hide all the sensitive stuff.&lt;/li&gt;
&lt;li&gt;Deal with &lt;strong&gt;static files&lt;/strong&gt; (a.k.a. the thing that almost drove me insane 🤯).&lt;/li&gt;
&lt;li&gt;Set up &lt;strong&gt;SSL redirects&lt;/strong&gt; for security in production.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After days of wrestling with deployment configs, I finally did it. The moment I clicked that URL and saw Moodify live on the web... That was a moment I’ll never forget. The adrenaline rush was insane!&lt;/p&gt;

&lt;p&gt;And then… there was silence. The app was running. My mood tracker was out there in the world. I did it. &lt;em&gt;We did it&lt;/em&gt; (me and my sanity). 🥳&lt;/p&gt;

&lt;h2&gt;
  
  
  🎁 The Link You’ve Been Waiting For...
&lt;/h2&gt;

&lt;p&gt;Want to see &lt;em&gt;Moodify&lt;/em&gt; in action? You can check it out &lt;strong&gt;LIVE&lt;/strong&gt; at &lt;a href="https://moodify-wmcd.onrender.com" rel="noopener noreferrer"&gt;moodify-wmcd.onrender.com&lt;/a&gt;. And if you’re curious to see how the magic happens, dive into the &lt;a href="https://github.com/mayowa-kalejaiye/Moodify.git" rel="noopener noreferrer"&gt;GitHub repository here&lt;/a&gt;. Trust me, the instructions are all laid out. You can even try it out yourself and maybe, just maybe, it’ll test your sanity like it did mine. 😜-psst 😗 don't mind the view of the home page👁️👁️😁&lt;/p&gt;

&lt;h2&gt;
  
  
  🎉 The Joy of Completion
&lt;/h2&gt;

&lt;p&gt;This project taught me more than I ever expected—not just about Django, databases, or deployment—but about &lt;strong&gt;myself&lt;/strong&gt;. The joy of sticking with something until it works. The resilience to not give up when the going gets tough. And the euphoria of seeing my work come to life.&lt;/p&gt;

&lt;p&gt;This is just the beginning. More projects will come, more bugs will break me, but if I’ve learned anything from Moodify, it’s that the joy of creation is always worth the pain of the process.&lt;/p&gt;

&lt;p&gt;To all my fellow developers and dreamers—keep pushing. Because at the end of every bug, there’s a breakthrough waiting. And trust me, when you reach it? It’ll feel like magic. ✨&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I need sleep😭😭&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Edit: I would be adding song suggestions based on the user;s mood through Spotify's API, I know it's limited 😔 so...I would look for ways to accommodate those who don't use Spotify...&lt;strong&gt;YOU AREN'T LEFT OUT&lt;/strong&gt;👋🏾😁&lt;/p&gt;

</description>
      <category>100daysofmiva</category>
      <category>100daysofcode</category>
      <category>django</category>
      <category>api</category>
    </item>
    <item>
      <title>Flask vs Django: The Epic Showdown Between Flexibility and Control!</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Thu, 10 Oct 2024 09:52:03 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/flask-vs-django-the-epic-showdown-between-flexibility-and-control-1ihp</link>
      <guid>https://dev.to/mayowakalejaiye/flask-vs-django-the-epic-showdown-between-flexibility-and-control-1ihp</guid>
      <description>&lt;p&gt;It's been days since I created a post😂, well it's not to late to continue👀...The #100daysofmiva shall prevail. "&lt;strong&gt;ONWARD&lt;/strong&gt;🏇🏾🏇🏾"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Day5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Alright, buckle up for a wild ride through the world of Flask and Django! 🎢 We're talking Python frameworks here, but with humor and suspense, because who said coding has to be boring? 👀&lt;/p&gt;

&lt;h2&gt;
  
  
  The Battle Begins: Flask vs Django 🥊
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Django&lt;/strong&gt; is like that super-organized, over-prepared friend who shows up to a picnic with Tupperware for every possible scenario: “&lt;em&gt;Oh, you're making sandwiches? I’ve brought the bread, the condiments, the cutlery, napkins, and a backup grill in case we need to barbecue.&lt;/em&gt;” It’s &lt;strong&gt;full-featured&lt;/strong&gt;, &lt;strong&gt;ready-to-go&lt;/strong&gt;, with everything baked in—authentication, ORM, admin interface, you name it. It’s your &lt;strong&gt;monolithic Swiss Army knife&lt;/strong&gt;. 🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flask&lt;/strong&gt;, on the other hand, is that chill friend who shows up to the picnic like, “&lt;em&gt;Yo, I just brought a bottle of water. Let’s see what happens&lt;/em&gt;.” &lt;strong&gt;Minimalist&lt;/strong&gt;, &lt;strong&gt;flexible&lt;/strong&gt;, and doesn’t care for too many rules. Flask gives you the &lt;strong&gt;freedom&lt;/strong&gt; to choose what you want, but only if you know what you're doing. It’s like giving you the keys to a blank canvas and saying, “&lt;strong&gt;Draw whatever you want, but don't mess it up&lt;/strong&gt;.” 🎨&lt;/p&gt;

&lt;h2&gt;
  
  
  Suspense Unfolds: When to Use Django 😏
&lt;/h2&gt;

&lt;p&gt;Imagine you’re building a &lt;strong&gt;castle&lt;/strong&gt;. You’ve got an army of workers, unlimited resources, and a grand vision to take over the world (or at least your local market). You don’t want to worry about the &lt;strong&gt;plumbing&lt;/strong&gt;, &lt;strong&gt;electricity&lt;/strong&gt;, and &lt;strong&gt;how to make a door open&lt;/strong&gt;. Enter &lt;strong&gt;Django&lt;/strong&gt;, the mighty builder! 🏰&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Django?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ready to rock&lt;/strong&gt;! It's got &lt;strong&gt;everything included&lt;/strong&gt;, like pre-made blueprints for a house. Need user authentication? Bam! Admin panel? Already there. It’s &lt;strong&gt;batteries-included&lt;/strong&gt; like your fancy, overpriced electronics. 🎮&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Serious business&lt;/strong&gt;: If you're dealing with a lot of features, a full-fledged backend, and you need things done fast—&lt;strong&gt;like, yesterday&lt;/strong&gt;—Django’s your knight in shining armor. ⚔️&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DRY (Don’t Repeat Yourself)&lt;/strong&gt;: Django’s got your back on keeping things tidy and organized. Think of it as your nagging parent telling you to pick up after yourself—but you’ll thank it later. 😅&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Dark Side: When to Use Flask 🌑
&lt;/h2&gt;

&lt;p&gt;But let’s say you don’t want a castle. You’re building a &lt;strong&gt;super-secret underground bunker&lt;/strong&gt;. You don’t want anyone to know what’s inside, and you’re only letting in a few trusted people. Enter Flask, your &lt;strong&gt;covert ops framework&lt;/strong&gt;. 🕶️&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Flask?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Freedom&lt;/strong&gt;: Flask gives you the &lt;strong&gt;steering wheel&lt;/strong&gt; and says, "&lt;em&gt;Drive&lt;/em&gt;." Want to take a detour? Go for it. Want to build a spaceship? Sure, no one's stopping you. 🛸&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lightweight&lt;/strong&gt;: It’s tiny, it’s fast, and it doesn’t shove extra tools in your face. Need a &lt;strong&gt;microservice&lt;/strong&gt; or a quick prototype? Flask’s the ninja for the job. &lt;strong&gt;Stealthy and efficient&lt;/strong&gt;. 🐱‍👤&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You like DIY&lt;/strong&gt;: Flask is for those who like to tinker and don’t mind getting their hands dirty. You build your own tools, like Iron Man in a cave. 🏗️&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  But Beware... 😨
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Flask&lt;/strong&gt;: "&lt;em&gt;You want an admin panel? Sure, &lt;strong&gt;build one yourself&lt;/strong&gt;&lt;/em&gt;." Oh, and &lt;strong&gt;user authentication&lt;/strong&gt;? Guess who's coding it from scratch? 😏🫠🫠🫠🫠&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Django&lt;/strong&gt;: "&lt;em&gt;Oh, you wanted flexibility? Too bad, stick with my rules or face the consequences.&lt;/em&gt;" You want to replace one component with another? &lt;strong&gt;Django will fight you&lt;/strong&gt;. It's like trying to change one tire on a speeding train.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Suspense Finale: Which Should You Pick? 😲
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;If you want to build a skyscraper&lt;/strong&gt; and don’t want to reinvent the wheel every two minutes, pick &lt;strong&gt;Django&lt;/strong&gt;. It's the framework that says, “&lt;strong&gt;I’ve got you covered, buddy!&lt;/strong&gt;”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;If you want to build a custom treehouse&lt;/strong&gt; with all the quirks that make it your treehouse, and you enjoy the thrill of &lt;strong&gt;complete control&lt;/strong&gt;, Flask is your spirit framework. But be prepared for** DIY everything**. 🛠️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And now, my friends, the choice is yours. &lt;strong&gt;The path of certainty&lt;/strong&gt; with Django, where everything is provided but at a cost of flexibility... or the &lt;strong&gt;path of mystery&lt;/strong&gt; with Flask, where you’re free to create—&lt;strong&gt;but watch your back&lt;/strong&gt;, because Flask leaves the heavy lifting to you! 🌟&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cue the dramatic music and exit&lt;/em&gt; 🎶&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4gkiwuug0whvglt3yzfl.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4gkiwuug0whvglt3yzfl.jpeg" alt="Pls Upvote" width="500" height="554"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>100daysofmiva</category>
      <category>django</category>
      <category>flask</category>
      <category>difference</category>
    </item>
    <item>
      <title>Building a Smart Network Optimization Tool: From Speed Testing to AI-Driven Optimization 🚀</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Fri, 30 Aug 2024 15:31:49 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/building-a-smart-network-optimization-tool-from-speed-testing-to-ai-driven-optimization-5f7o</link>
      <guid>https://dev.to/mayowakalejaiye/building-a-smart-network-optimization-tool-from-speed-testing-to-ai-driven-optimization-5f7o</guid>
      <description>&lt;p&gt;Hey everyone, I apologize for the delay. I've been trying to focus on things lately🥹 but I'm back to the glory of &lt;strong&gt;God&lt;/strong&gt;. I want to use this post as &lt;strong&gt;day #4&lt;/strong&gt; of the &lt;strong&gt;#100daysofmiva&lt;/strong&gt; challenge!😁...I was going through LinkedIn and saw something that led to another thing that made me think of this...enjoy!😉&lt;/p&gt;

&lt;h1&gt;
  
  
  Building a Smart Network Optimization Tool: From Speed Testing to AI-Driven Optimization 🚀
&lt;/h1&gt;

&lt;p&gt;In today's digital world, network performance is everything. Whether you're a business ensuring smooth online services, a data center maximizing server efficiency, or an everyday user tired of lag and buffering, understanding and optimizing your network can make a huge difference. 📶&lt;/p&gt;

&lt;p&gt;In this post, we'll walk through creating a Python-based network optimization tool that starts simple—with network speed tests—and evolves into a smarter, AI-driven solution that can predict and optimize network performance dynamically. Let's get started! 🔧&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Network Monitoring and Optimization? 🤔
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Networks&lt;/strong&gt; are the &lt;strong&gt;backbone&lt;/strong&gt; of digital services—any slowdown, bottleneck, or spike in latency can result in poor user experiences or lost revenue. Monitoring your network's performance helps you &lt;strong&gt;identify problems&lt;/strong&gt; before they &lt;strong&gt;impact your users&lt;/strong&gt;, and &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;optimization helps ensure your network runs at its best.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But monitoring isn't just about knowing your current speed; it's about understanding patterns, predicting future issues, and dynamically adjusting to maintain optimal performance. That’s where this tool comes in.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Building a Basic Network Speed Test Tool 🚀
&lt;/h2&gt;

&lt;p&gt;To begin our journey, we start with a simple Python script that tests network speed using the &lt;code&gt;speedtest&lt;/code&gt; library. This tool will check download speed, upload speed, and ping to give you a snapshot of your network's performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Snippet: Network Speed Test
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;speedtest&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;test_speed&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Running network speed test...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;st&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;speedtest&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Speedtest&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Get the best server
&lt;/span&gt;    &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_best_server&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c1"&gt;# Measure download speed
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Testing download speed...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;download_speed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;download&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Download Speed Test Progress&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Measure upload speed
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Testing upload speed...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;upload_speed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;upload&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Upload Speed Test Progress&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Get ping
&lt;/span&gt;    &lt;span class="n"&gt;ping_result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ping&lt;/span&gt;

    &lt;span class="c1"&gt;# Display results
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Download Speed: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;download_speed&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1_000_000&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Mbps&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Upload Speed: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;upload_speed&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1_000_000&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Mbps&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Ping: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ping_result&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; ms&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Getting the Best Server&lt;/strong&gt;: We find the server with the lowest ping for accurate results.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measuring Download and Upload Speeds&lt;/strong&gt;: We use &lt;code&gt;st.download()&lt;/code&gt; and &lt;code&gt;st.upload()&lt;/code&gt; to get the speeds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visual Feedback with&lt;/strong&gt; &lt;code&gt;tqdm&lt;/code&gt;: The &lt;code&gt;tqdm
&lt;/code&gt; library provides a visual progress bar for a better user experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2: Automating Network Performance Monitoring 🔄
&lt;/h2&gt;

&lt;p&gt;Manually checking your network speed every now and then isn't practical. Instead, we automate the process to monitor network performance over time using the &lt;code&gt;schedule&lt;/code&gt; library. This helps in identifying patterns and trends.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Snippet: Automating the Speed Test
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;schedule&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_scheduled_tests&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Network Optimization Tool is Running... Press Ctrl+C to stop.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;do&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test_speed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Change to desired interval
&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run_pending&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;run_scheduled_tests&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Automated Testing&lt;/strong&gt;: We use the schedule library to run our speed test at a set interval (e.g., every 10 minutes).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Continuous Monitoring&lt;/strong&gt;: This approach provides continuous data points to monitor network performance trends.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Logging and Analyzing the Results 📊
&lt;/h2&gt;

&lt;p&gt;Collecting data is useful only if we can analyze it later. This tool logs the results into a log file and a CSV file for easy analysis. This helps in understanding network performance over different times and conditions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Snippet: Logging Results
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;logging&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;

&lt;span class="c1"&gt;# Setup logging
&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;basicConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;network_optimization.log&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;INFO&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;log_results&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;download_speed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;upload_speed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ping_result&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;strftime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;%Y-%m-%d %H:%M:%S&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;log_message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;timestamp&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; | Download: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;download_speed&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Mbps | Upload: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;upload_speed&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; Mbps | Ping: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ping_result&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt; ms&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="c1"&gt;# Log to file
&lt;/span&gt;    &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log_message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Save to CSV
&lt;/span&gt;    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;network_performance.csv&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;a&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;csvfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;writer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;csvfile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;writer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writerow&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;download_speed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;upload_speed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ping_result&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Results logged successfully.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Call log_results inside test_speed after calculations
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Logging to File and CSV&lt;/strong&gt;: This allows for both human-readable logs and structured data for deeper analysis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timestamped Entries:&lt;/strong&gt; Every entry is timestamped, making it easy to correlate with other events.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 4: Introducing Network Optimization 🚀
&lt;/h2&gt;

&lt;p&gt;Monitoring is just the beginning. To make this tool truly powerful, it needs to analyze the data and provide actionable insights for network optimization. This could be optimizing routes, balancing loads, or even recommending changes to server configurations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code Snippet: Placeholder for Optimization
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;optimize_network&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="c1"&gt;# Placeholder function
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Analyzing network performance for optimizations...&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Example optimization logic
&lt;/span&gt;    &lt;span class="c1"&gt;# - Analyze trends
&lt;/span&gt;    &lt;span class="c1"&gt;# - Recommend server changes
&lt;/span&gt;    &lt;span class="c1"&gt;# - Suggest load balancing
&lt;/span&gt;    &lt;span class="c1"&gt;# For now, it's just a placeholder.
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Network optimization analysis complete. Suggestions will be available soon.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Analysis for Optimization&lt;/strong&gt;: This is where the real magic happens. In a future version, you/I could integrate advanced algorithms like Machine Learning for predicting network issues and dynamically optimizing them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: Advanced Techniques for Smart Network Optimization 🧠
&lt;/h2&gt;

&lt;p&gt;To take this tool to the next level, you can incorporate advanced techniques like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Anomaly Detection Algorithms:&lt;/strong&gt; Detect sudden drops or spikes in performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Machine Learning for Predictive Analysis:&lt;/strong&gt; Use models like LSTM for time-series forecasting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Routing and Load Balancing:&lt;/strong&gt; Optimize paths and loads in real-time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reinforcement Learning:&lt;/strong&gt; Create an adaptive system for continuous optimization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These techniques would turn our basic monitoring tool into a powerful, self-optimizing network management system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Visualizing Network Performance 📈
&lt;/h2&gt;

&lt;p&gt;Integrating with tools like &lt;strong&gt;Grafana&lt;/strong&gt; or &lt;strong&gt;Prometheus&lt;/strong&gt; can provide a real-time, visual dashboard for monitoring network performance, enabling quick decisions and optimizations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example Steps to Integrate:🤖
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Install Grafana/Prometheus&lt;/strong&gt; on your server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export Data&lt;/strong&gt; from our tool to the visualization platform.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Set Up Dashboards&lt;/strong&gt; to show real-time network performance metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Future Improvements and Extensions 🌟
&lt;/h2&gt;

&lt;p&gt;Some future directions for the tool include:😤&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Server Support:&lt;/strong&gt; Monitor and optimize across multiple servers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloud Integration:&lt;/strong&gt; Optimize for cloud environments like AWS, GCP, Azure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Advanced AI Models:&lt;/strong&gt; Use advanced models for deeper insights and optimizations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion 🎯
&lt;/h2&gt;

&lt;p&gt;We’ve journeyed from a simple network speed test tool to envisioning an AI-powered, self-optimizing network system. The potential for enhancing network performance is vast, and with these foundations, the sky is the limit! 🚀&lt;/p&gt;

&lt;p&gt;Give it a try, tweak it, and share your own experiences and enhancements!😉i'll be waiting&lt;/p&gt;

&lt;h2&gt;
  
  
  Credits and Acknowledgments 🙏
&lt;/h2&gt;

&lt;p&gt;Special thanks to &lt;strong&gt;ChatGPT by OpenAI&lt;/strong&gt; for providing guidance and insights on building this network optimization tool and suggesting enhancements for advanced AI-driven solutions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxf5rpgwa8zjyuzbfd3wq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxf5rpgwa8zjyuzbfd3wq.png" alt="description" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu4zbqcauye9wooj9u5vn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu4zbqcauye9wooj9u5vn.png" alt="description" width="638" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding and Happy Optimizing! May your networks be fast, your code clean, and your innovations endless.😁👌&lt;/p&gt;

</description>
      <category>100daysofmiva</category>
      <category>python</category>
      <category>speedtest</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Navigating Django REST URLs Like a Pro: A Fun and Easy Guide for Beginners 🌟</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Tue, 27 Aug 2024 19:04:50 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/navigating-django-rest-urls-like-a-pro-a-fun-and-easy-guide-for-beginners-22ma</link>
      <guid>https://dev.to/mayowakalejaiye/navigating-django-rest-urls-like-a-pro-a-fun-and-easy-guide-for-beginners-22ma</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hey, Django REST URLs, Let's Go!&lt;/strong&gt; 🚀&lt;br&gt;
Remember when I said I'll be visiting Django URLs in my CRUD API post...well...here you have it🎊 in day &lt;strong&gt;#3&lt;/strong&gt;&lt;br&gt;
So, you've got your Django project up and running and ready to hook up some APIs with the Django REST framework (DRF). Awesome! But... what’s up with these URLs? 🤔 Don’t worry, I got you!&lt;/p&gt;
&lt;h2&gt;
  
  
  1. The Basics: URL Configuration 🛤️
&lt;/h2&gt;

&lt;p&gt;Alright, first things first. Think of URLs as the addresses where your APIs live. Like, when you type a website URL into your browser, you're telling it where to go. With DRF, you do the same thing with your API endpoints!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Import Your Tools:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To get started, jump into your urls.py file.&lt;/li&gt;
&lt;li&gt;Import the path function (this guy helps match a URL to a view) and your views.
Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path
from .views import MyView
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;2. Map It Out:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next, you’ll create URL patterns. Each pattern tells Django, “Hey if someone visits this URL, send them to this view!”
Example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;urlpatterns = [
    path('my-endpoint/', MyView.as_view(), name='my-endpoint'),
]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Breakdown:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_'my-endpoint/'_&lt;/code&gt;&lt;/strong&gt;: The URL path (you can change this to whatever you like).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_MyView.as_view()_&lt;/code&gt;&lt;/strong&gt;: This is the view that handles the request. We'll get to views soon! 😎&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;_name='my-endpoint'_&lt;/code&gt;&lt;/strong&gt;: Naming your URLs is like giving them a nickname, so you can easily refer to them later.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  2. Project vs. App URLs: What's the Difference? 🤷‍♂️
&lt;/h2&gt;

&lt;p&gt;Okay, &lt;em&gt;quick detour!&lt;/em&gt; 🛣️ Django projects and apps are like a city and its neighborhoods:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Project URLs (&lt;code&gt;project/urls.py&lt;/code&gt;)&lt;/strong&gt;: The big map of your entire city (project). It usually includes general stuff like your homepage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App URLs (&lt;code&gt;app/urls.py&lt;/code&gt;)&lt;/strong&gt;: These are like the street names within a neighborhood (app). Each app has its own urls.py for handling specific stuff.
&lt;strong&gt;Tip&lt;/strong&gt;: Always include your app’s urls.py in your main project/urls.py. Like this:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path, include

urlpatterns = [
    path('api/', include('myapp.urls')),  # Includes URLs from your app
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  3. The include() Function: The Connector 🔗
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;&lt;code&gt;include()&lt;/code&gt;&lt;/strong&gt; function is your URL connector. It says, “Yo Django, include this set of URLs under this path.”&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: Let’s say you’ve got an app called blog and another called store.&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;&lt;code&gt;project/urls.py&lt;/code&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path, include

urlpatterns = [
    path('blog/', include('blog.urls')),  # All blog-related URLs will start with 'blog/'
    path('store/', include('store.urls')),  # All store-related URLs will start with 'store/'
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So if you visit &lt;strong&gt;&lt;code&gt;yourwebsite.com/blog/&lt;/code&gt;&lt;/strong&gt;, Django will look inside &lt;strong&gt;&lt;code&gt;blog/urls.py&lt;/code&gt;&lt;/strong&gt; for more directions. 🗺️&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Handling Dynamic URLs: Adding Some Spice 🌶️
&lt;/h2&gt;

&lt;p&gt;Sometimes, you want your URLs to handle variables, like &lt;strong&gt;&lt;code&gt;/products/42/&lt;/code&gt;&lt;/strong&gt; where &lt;strong&gt;&lt;code&gt;42&lt;/code&gt;&lt;/strong&gt; is the product ID.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;urlpatterns = [
    path('products/&amp;lt;int:id&amp;gt;/', ProductDetailView.as_view(), name='product-detail'),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;&amp;lt;int:id&amp;gt;&lt;/code&gt;&lt;/strong&gt;: This captures an integer from the URL and passes it to your view as id. So if you visit /products/42/, id will be 42.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Fun Fact&lt;/strong&gt;: You can also capture strings with &lt;strong&gt;&lt;code&gt;&amp;lt;str:name&amp;gt;&lt;/code&gt;&lt;/strong&gt; or even slugs with &lt;strong&gt;&lt;code&gt;&amp;lt;slug:slug&amp;gt;&lt;/code&gt;&lt;/strong&gt; (great for SEO-friendly URLs like &lt;strong&gt;&lt;code&gt;/blog/how-to-use-django&lt;/code&gt;&lt;/strong&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Putting It All Together: A Quick Recap 🧩
&lt;/h2&gt;

&lt;p&gt;Here's a little summary to keep you on track:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;URLs in DRF&lt;/strong&gt;: They're like street addresses for your APIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;path()&lt;/code&gt;&lt;/strong&gt;: Matches a URL to a view.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;include()&lt;/code&gt;&lt;/strong&gt;: Connects your app’s URLs to the project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic URLs&lt;/strong&gt;: Let you capture parts of the URL as variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Time!&lt;/strong&gt; 📚 Imagine you're building a bookstore API. Here's what your URL setup might look like:&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;&lt;code&gt;project/urls.py&lt;/code&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path, include

urlpatterns = [
    path('api/', include('bookstore.urls')),  # Include the bookstore app's URLs
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;strong&gt;&lt;code&gt;bookstore/urls.py&lt;/code&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path
from .views import BookListView, BookDetailView

urlpatterns = [
    path('books/', BookListView.as_view(), name='book-list'),
    path('books/&amp;lt;int:id&amp;gt;/', BookDetailView.as_view(), name='book-detail'),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, when someone hits &lt;strong&gt;&lt;code&gt;/api/books/&lt;/code&gt;&lt;/strong&gt;, they’ll get a list of all the books, and &lt;strong&gt;&lt;code&gt;/api/books/42/&lt;/code&gt;&lt;/strong&gt; will show details for the book with ID &lt;strong&gt;&lt;code&gt;42&lt;/code&gt;&lt;/strong&gt;. 📚&lt;/p&gt;

&lt;p&gt;And there you have it! 🎉 You're now on your way to mastering Django REST framework URLs. Keep practising, and soon it'll be second nature! 💪&lt;/p&gt;

&lt;p&gt;Got questions or want to dive deeper? Just ask! 😊&lt;/p&gt;

</description>
      <category>django</category>
      <category>api</category>
      <category>100daysofcode</category>
      <category>100daysofmiva</category>
    </item>
    <item>
      <title>Basic CRUD API using Django and Django REST Framework (DRF) || Simple API for managing a list of books.</title>
      <dc:creator>mayowa-kalejaiye</dc:creator>
      <pubDate>Sun, 25 Aug 2024 18:28:40 +0000</pubDate>
      <link>https://dev.to/mayowakalejaiye/basic-crud-api-using-django-and-django-rest-framework-drf-simple-api-for-managing-a-list-of-books-45e0</link>
      <guid>https://dev.to/mayowakalejaiye/basic-crud-api-using-django-and-django-rest-framework-drf-simple-api-for-managing-a-list-of-books-45e0</guid>
      <description>&lt;h2&gt;
  
  
  It's day #2 of #100daysofMiva guys🎊.
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/mayowa-kalejaiye" rel="noopener noreferrer"&gt;
        mayowa-kalejaiye
      &lt;/a&gt; / &lt;a href="https://github.com/mayowa-kalejaiye/BookMania-API" rel="noopener noreferrer"&gt;
        BookMania-API
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A simple API(It's still going to be upgraded) for managing list of books. Subscribe and see where this grows to
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;BookMania API&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;100 Days of Miva - API and Front-end Projects&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/mayowa-kalejaiye/BookMania-APIpublic/20240818_225416.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fmayowa-kalejaiye%2FBookMania-APIpublic%2F20240818_225416.png" alt="#100daysofMiva Banner"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Welcome to my repository for the #100daysofMiva challenge! This repository contains a collection of 100 simple API projects developed over 100 days. The challenge is all about consistency, learning, and building resilience through daily coding.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;About the Challenge&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;The #100daysofMiva challenge is designed to help developers, especially students of Miva Open University, develop a strong work ethic by committing to coding every day. The goal is to spend at least one hour each day working on a small project, pushing the boundaries of our skills, and documenting our progress.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Repository Structure&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;This repository is organized into three main sections, each corresponding to a different programming language:&lt;/p&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;/100daysofMiva
├── README.md
├── public/
│   ├── banner.jpg
│   └── (other assets)
└── Projects/
    ├── Day 1 | hello world API/
    │   ├── php/
    │   ├── nodejs/
    │   ├── python/
    │   └── README.md...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;&lt;li&gt;…&lt;/li&gt;&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/mayowa-kalejaiye/BookMania-API" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;You can check out the repository for further information...&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;note&lt;/strong&gt;:_Some parts have been upgraded and still under production...changes are due to happen as time goes....&lt;br&gt;
_&lt;br&gt;
&lt;strong&gt;Alright let's begin, Shall we ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7o09hjtk7ccuz8tqf1rh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7o09hjtk7ccuz8tqf1rh.png" alt="CRUD API testing" width="608" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkg6gu78x38ox8k27uvw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkg6gu78x38ox8k27uvw.png" alt="CRUD API testing" width="463" height="263"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Today I decided to work on a mini-project following the CRUD API pattern. This API currently allows me to:: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;C&lt;/strong&gt;reate: &lt;em&gt;Add new resources&lt;/em&gt;, &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;R&lt;/strong&gt;ead: &lt;em&gt;Retrieve or view existing resources&lt;/em&gt;, &lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;U&lt;/strong&gt;pdate: &lt;em&gt;Modify or update existing resources&lt;/em&gt;, and&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;D&lt;/strong&gt;elete:&lt;em&gt;Remove resources&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, in a CRUD API for a blog, you would have endpoints for creating a new post, retrieving posts, updating a post, and deleting a post. Each operation corresponds to a different HTTP method.:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;POST&lt;/strong&gt; &lt;em&gt;for Create&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GET&lt;/strong&gt; &lt;em&gt;for Read&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PUT&lt;/strong&gt; or &lt;strong&gt;PATCH&lt;/strong&gt; &lt;em&gt;for Update&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DELETE&lt;/strong&gt; &lt;em&gt;for Delete&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These APIs are fundamental in web development, allowing for the manipulation and retrieval of data.&lt;/p&gt;

&lt;p&gt;I will walk us through how I have created a straightforward CRUD API using Django and Django REST Framework (DRF) to manage a list of books. Let's get woke💪.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;em&gt;Step-by-Step Guide&lt;/em&gt;
&lt;/h2&gt;
&lt;h2&gt;
  
  
  1. Set Up Your Django Project
&lt;/h2&gt;

&lt;p&gt;First, make sure you have Django and Django REST Framework installed. You can install them using pip if you haven't already:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install django djangorestframework
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new Django project and a new app within it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;django-admin startproject myproject
cd myproject
python manage.py startapp books
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;startproject&lt;/strong&gt;: This command creates a new Django project. A project is a collection of settings for an instance of Django, including database configuration, Django-specific options, and application-specific settings.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;startapp&lt;/strong&gt;: This creates a new app within the project. Apps are components of your project that handle specific functionality (e.g., user management).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Configure Your Django Project
&lt;/h2&gt;

&lt;p&gt;Add your new app and DRF to your &lt;code&gt;INSTALLED_APPS&lt;/code&gt; in &lt;code&gt;myproject/settings.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSTALLED_APPS = [
   ...
   'rest_framework',
   'books',
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Define the Model
In &lt;code&gt;books/models.py&lt;/code&gt;, define a Book model:
this is where you design how you want to input data, it depends on what exactly you want to do
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.db import models

class Book(models.Model):
    title = models.CharField(max_length=100)
    author = models.CharField(max_length=100)
    published_date = models.DateField()
    isbn = models.CharField(max_length=13, unique=True)
    pages = models.IntegerField()
    cover = models.URLField(blank=True)
    language = models.CharField(max_length=20)

    def __str__(self):
        return self.title

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you run migrations to create the database schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py makemigrations
python manage.py migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Always do this once your &lt;code&gt;books/models.py&lt;/code&gt; has been updated, iterated or refurbished....so that it will be consistent &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Moving on...😁&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Create a Serializer
&lt;/h2&gt;

&lt;p&gt;Create a serializer for your model in &lt;code&gt;books/serializers.py&lt;/code&gt;:&lt;br&gt;
By using serializers, you ensure that the data your API sends and receives is well-organized, validated, and easily understandable, making it a critical part of any Django REST API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from rest_framework import serializers
from .models import Book

class BookSerializer(serializers.ModelSerializer):
    class Meta:
        model = Book
        fields = '__all__'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Create Views
&lt;/h2&gt;

&lt;p&gt;Define views for your API in &lt;code&gt;books/views.py&lt;/code&gt; using DRF’s viewsets: By understanding views, you gain control over how data flows through the application, making it a critical aspect of building APIs with Django REST Framework.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from rest_framework import viewsets
from .models import Book
from .serializers import BookSerializer

class BookViewSet(viewsets.ModelViewSet):
    queryset = Book.objects.all()
    serializer_class = BookSerializer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Now we move to our routing...🥹 Kudos to you for coming this far😁...&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Configure URLs
&lt;/h2&gt;

&lt;p&gt;Set up URLs to route API requests. First, create a file &lt;code&gt;books/urls.py&lt;/code&gt;: &lt;strong&gt;URLs&lt;/strong&gt; in Django map the paths of incoming HTTP requests to the appropriate view functions or classes. In Django REST Framework (DRF), URLs are used to define how different endpoints of your API are accessed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import BookViewSet

router = DefaultRouter()
router.register(r'books', BookViewSet)

urlpatterns = [
    path('', include(router.urls)),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is path()?&lt;/strong&gt;&lt;br&gt;
In Django, &lt;em&gt;&lt;strong&gt;path()&lt;/strong&gt;&lt;/em&gt; is a function used to define a URL pattern and link it to a specific view.&lt;br&gt;
Think of it as a map that directs incoming web requests to the correct view, which then processes the request and returns a response. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is include()?&lt;/strong&gt;&lt;br&gt;
The &lt;strong&gt;&lt;em&gt;include()&lt;/em&gt;&lt;/strong&gt; function allows you to include other URL configurations. In this example, it includes the URLs automatically generated by a DRF router.&lt;/p&gt;

&lt;p&gt;Then, include these URLs in the projects's &lt;code&gt;myproject/urls.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('books.urls')),
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understanding URLs might be really tricky so...&lt;br&gt;
&lt;strong&gt;&lt;em&gt;I WILL EXPLAIN EVERYTHING ABOUT URLs IN MY NEXT POST&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Digging through to the next step....😤&lt;/p&gt;
&lt;h2&gt;
  
  
  7. Run the Development Server
&lt;/h2&gt;

&lt;p&gt;Start the Django development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python manage.py runserver
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your API should be accessible at &lt;code&gt;http://localhost:8000/api/books/&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fun step-8. Test the API
&lt;/h2&gt;

&lt;p&gt;You can test the API using tools like &lt;strong&gt;Postman&lt;/strong&gt; or &lt;strong&gt;curl&lt;/strong&gt;, or visit the URL in your browser to use Django REST Framework's built-in web interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now&lt;/strong&gt; what is coding without bugs huh?😉Some of us might encounter errors on the way but I've got you covered😁///&lt;br&gt;
Here are some common errors and their solutions specifically for the CRUD API project you just worked on:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error: ModuleNotFoundError: No module named 'your_app'&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Ensure that your app is listed in INSTALLED_APPS in settings.py, and check for any typos in your urls.py or views.py.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error: ImportError: Could not import 'rest_framework'&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Install Django REST framework using pip install djangorestframework, and ensure it's added to INSTALLED_APPS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error: AssertionError: 'YourViewSet' should either include a serializer_class attribute, or override the get_serializer_class() method.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: In your views.py, make sure your ViewSet has a serializer_class attribute that points to the correct serializer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error: IntegrityError: UNIQUE constraint failed&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: This occurs when trying to insert duplicate values in a field that requires unique entries. Make sure the data you are saving does not violate this constraint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error: ProgrammingError: relation "your_model" does not exist&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Run python manage.py makemigrations and python manage.py migrate to ensure the database schema is up to date.&lt;/p&gt;

&lt;p&gt;IF YOU HAVE ANY QUESTION, FEEL OBLIGED TO PUT THEM IN THE COMMENT SECTION...😉&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;br&gt;
Happy Growing!&lt;/p&gt;

</description>
      <category>django</category>
      <category>djangorest</category>
      <category>100dayofmiva</category>
      <category>100daysofcode</category>
    </item>
  </channel>
</rss>
