<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flask API Archives - SkilloTour</title>
	<atom:link href="https://skillotour.in/tag/flask-api/feed/" rel="self" type="application/rss+xml" />
	<link>https://skillotour.in/tag/flask-api/</link>
	<description>Website to upgrade your skills</description>
	<lastBuildDate>Wed, 05 Mar 2025 18:23:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>

<image>
	<url>https://skillotour.in/wp-content/uploads/2025/01/cropped-apple-touch-icon-1-32x32.png</url>
	<title>Flask API Archives - SkilloTour</title>
	<link>https://skillotour.in/tag/flask-api/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to create an API and deploy it on the Cloud for free</title>
		<link>https://skillotour.in/2025/03/05/how-to-create-an-api-and-deploy-it-on-the-cloud-for-free/</link>
					<comments>https://skillotour.in/2025/03/05/how-to-create-an-api-and-deploy-it-on-the-cloud-for-free/#respond</comments>
		
		<dc:creator><![CDATA[Naveen Naik]]></dc:creator>
		<pubDate>Wed, 05 Mar 2025 18:23:55 +0000</pubDate>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[API Development]]></category>
		<category><![CDATA[Cloud Hosting]]></category>
		<category><![CDATA[Flask API]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python-flask]]></category>
		<guid isPermaLink="false">https://skillotour.in/?p=385</guid>

					<description><![CDATA[<p>Hello readers, in this article, I will explain how to create an API and deploy it in the cloud for free. I will use Flask (a web framework of Python) to create the APIs and host them on the Oracle Cloud. Prerequisites Overview 1. Introduction API stands for Application Programming Interface. APIs are the means [&#8230;]</p>
<p>The post <a href="https://skillotour.in/2025/03/05/how-to-create-an-api-and-deploy-it-on-the-cloud-for-free/">How to create an API and deploy it on the Cloud for free</a> appeared first on <a href="https://skillotour.in">SkilloTour</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Hello readers, in this article, I will explain how to create an API and deploy it in the cloud for free. I will use Flask (a web framework of Python) to create the APIs and host them on the Oracle Cloud. </p>



<h2 class="wp-block-heading">Prerequisites</h2>



<ul class="wp-block-list">
<li>Python Programming basics</li>



<li>Linux commands basics</li>



<li>Oracle cloud free tier account or any cloud platform account with free trial(GCP, AWS etc).</li>
</ul>



<h2 class="wp-block-heading">Overview</h2>



<ol class="wp-block-list is-style-default">
<li><a href="#introduction">Introduction</a></li>



<li><a href="#dependencies">Install required dependencies on the VM</a></li>



<li><a href="#flask-api">Create a Flask API</a></li>



<li><a href="#output">Test the API (Output)</a></li>
</ol>



<h2 class="wp-block-heading" id="introduction">1. Introduction</h2>



<p><strong>API</strong> stands for Application Programming Interface. APIs are the means to connect between various apps or programs. For example, we can connect an e-commerce app like Amazon with a payment app like Google Pay or Phonepe to make payments for purchasing items. Here Amazon and Payment apps communicate using APIs. APIs can be multiple types including REST APIs, GraphQL APIs etc. To simplify the process, let&#8217;s create a simple REST API in Python.</p>



<p><strong>REST APIs</strong> are accessible through HTTP. Using REST APIs, we can perform CRUD operations by calling a website URL. When we call the URL, the particular software performs backend processes like fetching data from the database, performing calculations and returning data in the form of JSON.</p>



<p>JSON format is the common language used by APIs for faster communication. For example, two applications communicate through API calls using JSON language. <a href="https://www.geeksforgeeks.org/communication-between-two-programs-using-json/" target="_blank" rel="noreferrer noopener">You can refer here for more details.</a></p>



<h2 class="wp-block-heading" id="dependencies">2. Install the required dependencies on the VM</h2>



<p>If you have a cloud account, go to your cloud platform and start a Virtual Machine(VM). If you don&#8217;t have an account, you can get an Oracle Cloud account from <a href="https://www.oracle.com/in/cloud/free/" target="_blank" rel="noreferrer noopener">here</a> and start a VM for free. After starting the instance(VM), you can connect to the instance using the ssh command below:</p>



<p class="has-text-align-left is-style-default has-base-color has-text-color has-background has-link-color wp-elements-fa37bfce7986986d979f376d230b9854" style="border-style:none;border-width:0px;background-color:#373737;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><code>  ssh -i your-private-key-path user@your-ip</code></p>



<p>In the above command, replace <strong>your-private-key-path</strong> with the path where you stored the private key, the user generally would be Ubuntu in the case of Oracle and your-ip is the public IP with which you connect to the VM.</p>



<p>After connecting to the VM, update the package lists with the below command:</p>



<p class="has-text-align-left is-style-default has-base-color has-text-color has-background has-link-color wp-elements-5be22325429f39134e6fe131d8b82d9a" style="border-style:none;border-width:0px;background-color:#373737;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><code>  sudo apt update &amp;&amp; sudo apt upgrade -y</code></p>



<p>Install flask using pip as below:</p>



<p class="has-text-align-left is-style-default has-base-color has-text-color has-background has-link-color wp-elements-0794fbbd55214ef12251c2907927d000" style="border-style:none;border-width:0px;background-color:#373737;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><code>  pip3 install flask</code></p>



<p>We are done with installing dependencies in our VM. Let&#8217;s create our API.</p>



<h2 class="wp-block-heading" id="flask-api">3. Create a Flask API</h2>



<p>Create a new directory for our flask API and name it flask-api:</p>



<p class="has-text-align-left is-style-default has-base-color has-text-color has-background has-link-color wp-elements-0b42ac48d3e35cbe630be2531fc7653d" style="border-style:none;border-width:0px;background-color:#373737;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><code>  mkdir flask-api</code></p>



<p>Switch to our new directory:</p>



<p class="has-text-align-left is-style-default has-base-color has-text-color has-background has-link-color wp-elements-17a4bd64d87c31c24a1f57a96b49217f" style="border-style:none;border-width:0px;background-color:#373737;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><code>  cd flask-api</code></p>



<p>Create a Python file named app.py and write the below code in it using nano or vi editor:</p>



<pre style="background-color: #282c34; color: #abb2bf; padding: 15px; border-radius: 5px; overflow-x: auto; font-size: 14px;">
<code style="font-family: monospace;">
<span style="color: #c678dd;">from</span> <span style="color: #e5c07b;">flask</span> <span style="color: #c678dd;">import</span> <span style="color: #e5c07b;">Flask</span>, <span style="color: #e5c07b;">jsonify</span>

<span style="color: #61afef;">app</span> = <span style="color: #e06c75;">Flask</span>(<span style="color: #98c379;">__name__</span>)

<span style="color: #e5c07b;">@app.route</span>(<span style="color: #98c379;">'/message'</span>)
<span style="color: #61afef;">def</span> <span style="color: #d19a66;">home</span>():
    <span style="color: #98c379;">return</span> <span style="color: #e5c07b;">jsonify</span>({<span style="color: #98c379;">"message"</span>: <span style="color: #98c379;">"Hello, You created an API!"</span>})

<span style="color: #61afef;">if</span> <span style="color: #98c379;">__name__</span> == <span style="color: #98c379;">'__main__'</span>:
    <span style="color: #61afef;">app</span>.run(host=<span style="color: #98c379;">'0.0.0.0'</span>, port=<span style="color: #d19a66;">5000</span>)
</code>
</pre>




<p>In the above code, <strong>port=5000</strong> indicates that the Flask app is running at <strong>your-ip:5000</strong>. The line host=&#8217;0.0.0.0&#8242; makes the API accessible from any IP apart from localhost. <strong>@app.route(&#8216;/message&#8217;)</strong> routes our app to be called at <strong>your-ip:5000/message</strong>. </p>



<h2 class="wp-block-heading" id="output">4. Test the API(Output)</h2>



<p>Run the below command to start the Flask web server:</p>



<p class="has-text-align-left is-style-default has-base-color has-text-color has-background has-link-color wp-elements-e8fc98df0ad1fcf645b6ff088f0a3083" style="border-style:none;border-width:0px;background-color:#373737;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><code>  python3 app.py</code></p>



<p>You can see the output in the terminal as shown below:</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="263" src="https://skillotour.in/wp-content/uploads/2025/03/running-1-1024x263.png" alt="" class="wp-image-396" srcset="https://skillotour.in/wp-content/uploads/2025/03/running-1-1024x263.png 1024w, https://skillotour.in/wp-content/uploads/2025/03/running-1-300x77.png 300w, https://skillotour.in/wp-content/uploads/2025/03/running-1-768x198.png 768w, https://skillotour.in/wp-content/uploads/2025/03/running-1-150x39.png 150w, https://skillotour.in/wp-content/uploads/2025/03/running-1.png 1205w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>Note</strong>: You see a warning because Flask&#8217;s web server is for development purposes only as it lacks security and scalability. We should use a production-ready WSGI server like Gunicorn to run the API in a production environment. </p>



<p>To test the output, open your local web browser and visit your-ip:5000/message. For example, if your VM&#8217;s public IP is 144.24.142.183, you can visit http://144.24.142.183:5000/message to see the output. Sample output is shown below:</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" width="381" height="124" src="https://skillotour.in/wp-content/uploads/2025/03/output.png" alt="" class="wp-image-393" style="width:633px;height:auto" srcset="https://skillotour.in/wp-content/uploads/2025/03/output.png 381w, https://skillotour.in/wp-content/uploads/2025/03/output-300x98.png 300w, https://skillotour.in/wp-content/uploads/2025/03/output-150x49.png 150w" sizes="(max-width: 381px) 100vw, 381px" /></figure>



<p>Congratulations on creating your own API and successfully hosting it in the cloud for free. Once you practise developing APIs, You can create complex APIs based on authentication, e-commerce etc. </p>
<p>The post <a href="https://skillotour.in/2025/03/05/how-to-create-an-api-and-deploy-it-on-the-cloud-for-free/">How to create an API and deploy it on the Cloud for free</a> appeared first on <a href="https://skillotour.in">SkilloTour</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://skillotour.in/2025/03/05/how-to-create-an-api-and-deploy-it-on-the-cloud-for-free/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
