<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Web on Ghafoor's Personal Blog</title><link>http://ghafoorsblog.com/categories/web/</link><description>Recent content in Web on Ghafoor's Personal Blog</description><generator>Hugo</generator><language>en</language><managingEditor>noreply@example.com (AG Sayyed)</managingEditor><webMaster>noreply@example.com (AG Sayyed)</webMaster><copyright>Copyright © 2024-2026 AG Sayyed. All Rights Reserved.</copyright><lastBuildDate>Sat, 16 May 2026 17:42:12 +0100</lastBuildDate><atom:link href="http://ghafoorsblog.com/categories/web/index.xml" rel="self" type="application/rss+xml"/><item><title>Deploying Flask App</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/007-deploying-flask-app/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/007-deploying-flask-app/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers installing Flask, creating and deploying a Python web application, and using Flask's features for CRUD operations and template rendering. It includes step-by-step instructions and code examples for building and running Flask apps.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-flask-and-crud-operations"&gt;Introduction to Flask and CRUD Operations&lt;/h2&gt;
&lt;p&gt;Flask is a micro-framework for building web applications quickly and easily with Python. It supports CRUD operations—Create, Read, Update, and Delete—using HTTP methods such as POST, GET, PUT, PATCH, and DELETE.&lt;/p&gt;</description></item><item><title>Dynamic Routes</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/005-dynamic-routes/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/005-dynamic-routes/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores dynamic routing in Flask, including how to pass parameters in URLs, call external APIs, and use parameter types for robust RESTful endpoints. It covers practical examples for integrating external data and validating user input in web applications.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="calling-external-apis-in-flask"&gt;Calling External APIs in Flask&lt;/h2&gt;
&lt;p&gt;Flask can interact with external APIs using the Python &lt;code&gt;requests&lt;/code&gt; library. This allows applications to fetch, process, and return data from third-party services.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;requests&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;jsonify&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 3&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 4&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vm"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 5&lt;/span&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 6&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/author&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 7&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;author_info&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 8&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;https://openlibrary.org/search/authors.json?q=Michael+Crichton&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt; 9&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;10&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;11&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;12&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;message&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;Something went wrong.&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;13&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;14&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;message&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;Server error.&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This example fetches author data from the OpenLibrary API and returns the result to the client, handling different status codes appropriately.&lt;/p&gt;</description></item><item><title>Error Handling</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/006-error-handling/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/006-error-handling/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers HTTP status codes, error handling in Flask, and best practices for returning error responses from API endpoints. It explains status code categories, custom error responses, and application-level error handlers for robust API design.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="understanding-http-status-codes"&gt;Understanding HTTP Status Codes&lt;/h2&gt;
&lt;p&gt;Every HTTP response includes a three-digit status code that indicates the result of the request. Status codes are grouped into categories:&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Code Range&lt;/th&gt;
 &lt;th&gt;Category&lt;/th&gt;
 &lt;th&gt;Description&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;100–199&lt;/td&gt;
 &lt;td&gt;Informational&lt;/td&gt;
 &lt;td&gt;Request received, continuing process&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;200–299&lt;/td&gt;
 &lt;td&gt;Success&lt;/td&gt;
 &lt;td&gt;Request received and processed successfully&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;300–399&lt;/td&gt;
 &lt;td&gt;Redirection&lt;/td&gt;
 &lt;td&gt;Further action needed to complete request&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;400–499&lt;/td&gt;
 &lt;td&gt;Client Error&lt;/td&gt;
 &lt;td&gt;Error in the request from the client&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;500–599&lt;/td&gt;
 &lt;td&gt;Server Error&lt;/td&gt;
 &lt;td&gt;Error on the server side&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Common codes include:&lt;/p&gt;</description></item><item><title>Flask Features</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/002-flask-features/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/002-flask-features/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores the core features of Flask, its dependencies, installation process, and how it compares to Django. It highlights Flask’s extensibility, built-in tools, and popular community extensions for building web applications.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-flask"&gt;Introduction to Flask&lt;/h2&gt;
&lt;p&gt;Flask is a micro web framework for Python, designed to create web applications with minimal dependencies. It is unopinionated, allowing developers to choose their tools and extensions.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="flask-dependencies-and-installation"&gt;Flask Dependencies and Installation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Flask requires Python 3.7 or higher (e.g., Flask 2.2.2).&lt;/li&gt;
&lt;li&gt;Install Flask using pip, preferably in a virtual environment:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;python -m venv venv
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;source&lt;/span&gt; venv/bin/activate
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;pip install &lt;span class="nv"&gt;flask&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;2.2.2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Pin dependency versions in your application to ensure reproducibility across environments.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="built-in-features-of-flask"&gt;Built-in Features of Flask&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Development web server for running applications locally&lt;/li&gt;
&lt;li&gt;Interactive debugger with browser-based stack trace&lt;/li&gt;
&lt;li&gt;Standard Python logging for application and custom logs&lt;/li&gt;
&lt;li&gt;Built-in testing support for test-driven development&lt;/li&gt;
&lt;li&gt;Access to request and response objects for customizing web interactions&lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Feature&lt;/th&gt;
 &lt;th&gt;Description&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;Web Server&lt;/td&gt;
 &lt;td&gt;Runs apps in development mode&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Debugger&lt;/td&gt;
 &lt;td&gt;Shows interactive traceback in browser&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Logging&lt;/td&gt;
 &lt;td&gt;Uses Python logging for app and custom messages&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Testing&lt;/td&gt;
 &lt;td&gt;Supports test-driven development&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Request/Response&lt;/td&gt;
 &lt;td&gt;Enables argument parsing and custom responses&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;hr&gt;
&lt;h2 id="additional-features-and-extensions"&gt;Additional Features and Extensions&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Static asset support (CSS, JS, images) via template tags&lt;/li&gt;
&lt;li&gt;Dynamic page generation using Jinja templating&lt;/li&gt;
&lt;li&gt;Routing and dynamic URLs for RESTful services&lt;/li&gt;
&lt;li&gt;Global error handlers and user session management&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Popular community extensions:&lt;/p&gt;</description></item><item><title>Libraries and Framework</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/001-libraries-framework/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/001-libraries-framework/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores the distinctions between Python libraries and frameworks, focusing on how frameworks like Flask simplify web application development. It introduces Flask’s core features and practical setup for building web apps.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-libraries-and-frameworks"&gt;Introduction to Libraries and Frameworks&lt;/h2&gt;
&lt;p&gt;Libraries and frameworks are essential tools in Python development. Libraries provide reusable code for specific tasks, while frameworks offer a structured foundation for building applications.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="python-libraries"&gt;Python Libraries&lt;/h2&gt;
&lt;p&gt;A library is a collection of modules or packages that provide specific functionality. Libraries are used to perform tasks such as data analysis, visualization, or machine learning (e.g., NumPy, Pandas).&lt;/p&gt;</description></item><item><title>Response and Request Objects</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/004-using-web-api/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/004-using-web-api/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores how Flask handles HTTP requests and responses, including the use of the request and response objects, their key attributes, and methods for extracting and sending data. It covers HTTP method handling, headers, query parameters, and custom responses in Flask applications.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="understanding-flask-request-and-response-objects"&gt;Understanding Flask Request and Response Objects&lt;/h2&gt;
&lt;p&gt;Flask provides two essential objects for handling web communication: the request object and the response object. These objects allow applications to receive data from clients and send data back, supporting a wide range of HTTP methods and custom behaviors.&lt;/p&gt;</description></item><item><title>Routes</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/003-routes/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/02-module/003-routes/</guid><description>&lt;p class="lead text-primary"&gt;
This document details how to create and configure routes in Flask, return responses, manage configuration, and structure projects for maintainability. It covers decorators, JSON responses, environment variables, and best practices for organizing Flask code.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-flask-routes"&gt;Introduction to Flask Routes&lt;/h2&gt;
&lt;p&gt;Routes in Flask define how URLs are handled by the application. Each route is associated with a function that returns a response to the client.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="creating-a-basic-flask-application"&gt;Creating a Basic Flask Application&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Install Flask and create a Python file (e.g., &lt;code&gt;app.py&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Import the &lt;code&gt;Flask&lt;/code&gt; class and instantiate the app:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vm"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;
&lt;li&gt;Define a route using the &lt;code&gt;@app.route&lt;/code&gt; decorator:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello_world&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;&amp;lt;b&amp;gt;my first Flask application in action!&amp;lt;/b&amp;gt;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h2 id="running-the-flask-application"&gt;Running the Flask Application&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Set environment variables for the app and environment:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;FLASK_APP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;app.py
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;FLASK_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;development
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;flask run
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;The app runs on &lt;code&gt;http://localhost:5000&lt;/code&gt; by default.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;--app&lt;/code&gt; and &lt;code&gt;--debug&lt;/code&gt; flags for configuration and development mode.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="returning-responses-and-json"&gt;Returning Responses and JSON&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Return text or HTML directly from route functions.&lt;/li&gt;
&lt;li&gt;To return JSON, return a serializable object (e.g., dictionary) or use &lt;code&gt;jsonify&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;1&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;jsonify&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;2&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;/json&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;3&lt;/span&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;json_example&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="ln"&gt;4&lt;/span&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Hello, JSON!&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;The response will have content type &lt;code&gt;application/json&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="flask-configuration-options"&gt;Flask Configuration Options&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Set configuration via environment variables, the &lt;code&gt;app.config&lt;/code&gt; object, or external files.&lt;/p&gt;</description></item><item><title>Web Api</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/01-module/003-web-api/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/08-ai-apps-python-flask/01-module/003-web-api/</guid><description>&lt;p class="lead text-primary"&gt;
This document explores the structure and function of web applications and APIs, clarifying their differences, architectures, and how they enable seamless communication between software systems. Readers will learn about web app components, API roles, and real-world examples of their integration.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-web-applications-and-apis"&gt;Introduction to Web Applications and APIs&lt;/h2&gt;
&lt;p&gt;A web application (web app) is a program stored on a remote server and delivered over the internet. Users interact with web apps through browsers, accessing services like e-commerce, webmail, and more. Most web apps are compatible with all modern browsers, regardless of platform.&lt;/p&gt;</description></item><item><title>Rest Api</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/07-python-datascience/05-module/003-rest-api-2/</link><pubDate>Thu, 24 Jul 2025 14:07:03 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/07-python-datascience/05-module/003-rest-api-2/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers the use of the Python Requests library for HTTP communication, including GET and POST requests, query strings, request and response objects, and practical examples for interacting with web APIs.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-the-requests-library"&gt;Introduction to the Requests Library&lt;/h2&gt;
&lt;p&gt;The Requests library in Python simplifies sending HTTP/1.1 requests. It supports GET and POST methods, allowing easy interaction with web servers and APIs.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="making-get-requests"&gt;Making GET Requests&lt;/h2&gt;
&lt;p&gt;Import the library and send a GET request:&lt;/p&gt;</description></item><item><title>HTTP Protocols and REST APIs</title><link>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/07-python-datascience/05-module/002-http-protocols/</link><pubDate>Thu, 24 Jul 2025 14:01:59 +0000</pubDate><author>noreply@example.com (AG Sayyed)</author><guid>http://ghafoorsblog.com/courses/ibm/fullstack-content/fullstack-pcert/07-python-datascience/05-module/002-http-protocols/</guid><description>&lt;p class="lead text-primary"&gt;
This document covers the fundamentals of REST APIs, the HTTP protocol, URL structure, request and response cycles, status codes, and HTTP methods. Readers will learn how web communication works and how REST APIs facilitate data transfer between clients and servers.
&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="introduction-to-http-and-rest-apis"&gt;Introduction to HTTP and REST APIs&lt;/h2&gt;
&lt;p&gt;The HTTP protocol is a standard for transferring information over the web, including REST APIs. REST APIs operate by sending requests and receiving responses using HTTP messages, often containing JSON data.&lt;/p&gt;</description></item></channel></rss>