<?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: Rohith ND</title>
    <description>The latest articles on DEV Community by Rohith ND (@ndrohith).</description>
    <link>https://dev.to/ndrohith</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%2F843476%2F2160c94a-4e74-42fc-b2d1-dc26b1e12339.jpg</url>
      <title>DEV Community: Rohith ND</title>
      <link>https://dev.to/ndrohith</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ndrohith"/>
    <language>en</language>
    <item>
      <title>🚀Zeroagent - World's first AI Work Assistant</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Mon, 25 Nov 2024 09:09:28 +0000</pubDate>
      <link>https://dev.to/ndrohith/zeroagent-worlds-first-ai-work-assistant-4bj2</link>
      <guid>https://dev.to/ndrohith/zeroagent-worlds-first-ai-work-assistant-4bj2</guid>
      <description>&lt;p&gt;An agentic platform built to boost productivity and optimize workflows by eliminating manual tasks, reducing app-switching, and consolidating scattered data across multiple platforms. &lt;/p&gt;

&lt;p&gt;👉 Get Started for Free - &lt;a href="https://zeroagent.io/" rel="noopener noreferrer"&gt;https://zeroagent.io/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🌟 What makes Zeroagent special?
&lt;/h3&gt;

&lt;p&gt;1️⃣ Simplify Your Work: Just prompt to handle tasks, freeing up your time for what matters most.&lt;br&gt;
2️⃣ AI-Driven Efficiency: Automate repetitive tasks across multiple business apps, all with simple commands.&lt;br&gt;
3️⃣ Seamless Integration: Zeroagent connects to your existing tools, ensuring you never have to switch between apps again.&lt;br&gt;
4️⃣ Boost Team Collaboration: Enhance team coordination by automating notifications, meeting schedules, and much more.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔧 How it works:
&lt;/h3&gt;

&lt;p&gt;Zeroagent connects with your apps and helps you with everything from scheduling meetings to managing projects and data. ✨ All it takes is a simple prompt like: "Schedule a sales team meeting and notify on Slack."&lt;/p&gt;

&lt;h3&gt;
  
  
  💼 Who is this for?
&lt;/h3&gt;

&lt;p&gt;Individuals and enterprises to save time, automate repetitive tasks, improve collaboration, and boost productivity focusing on what truly matters.&lt;/p&gt;

&lt;p&gt;We can’t wait to see how Zeroagent helps you achieve more with less effort! Try for free 👇 &lt;br&gt;
🌐 &lt;a href="https://zeroagent.io/" rel="noopener noreferrer"&gt;https://zeroagent.io/&lt;/a&gt;&lt;br&gt;
📄 &lt;a href="https://docs.zeroagent.io/" rel="noopener noreferrer"&gt;https://docs.zeroagent.io/&lt;/a&gt;&lt;br&gt;
⏯️ &lt;a href="https://www.youtube.com/@zeroagentio" rel="noopener noreferrer"&gt;https://www.youtube.com/@zeroagentio&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>startup</category>
      <category>management</category>
      <category>devops</category>
    </item>
    <item>
      <title>Build Your First REST API in minutes using Zeromagic Flow Builder</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Tue, 01 Oct 2024 05:13:28 +0000</pubDate>
      <link>https://dev.to/ndrohith/build-your-first-rest-api-in-minutes-using-zeromagic-flow-builder-5dn8</link>
      <guid>https://dev.to/ndrohith/build-your-first-rest-api-in-minutes-using-zeromagic-flow-builder-5dn8</guid>
      <description>&lt;p&gt;In this blog post, we'll explore how to create your first REST API on the &lt;a href="https://zeromagic.cloud/" rel="noopener noreferrer"&gt;Zeromagic&lt;/a&gt; Platform. Whether you're a beginner or an experienced developer, our intuitive Workflow Builder will guide you through setting up endpoints, defining data models, and handling HTTP requests. Let's dive in and see how you can quickly build and deploy a functional REST API with GET and POST methods, empowering your applications with seamless data interactions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Login to Project Console
&lt;/h3&gt;

&lt;p&gt;Login to &lt;a href="https://console.zeromagic.cloud/" rel="noopener noreferrer"&gt;Zeromagic Platform&lt;/a&gt; and go to you &lt;code&gt;Project Console&lt;/code&gt;. Now navigate to &lt;code&gt;Rest API&lt;/code&gt; in the sidebar of the console.&lt;/p&gt;

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



&lt;p&gt;Modules are often used to structure and organize API endpoints when building RESTful APIs. Each module can represent a specific domain or resource within your application.&lt;/p&gt;



&lt;h3&gt;
  
  
  Step 2: Create a new Module
&lt;/h3&gt;

&lt;p&gt;Now click on &lt;code&gt;Create Module&lt;/code&gt; button to create a new module. This open a form to create a new module. Enter the &lt;code&gt;Name&lt;/code&gt; and &lt;code&gt;API path&lt;/code&gt; of the module.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note : API Path only follows the trailing slash.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4um4xmtz3loe5dn613a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4um4xmtz3loe5dn613a.png" alt="CreateModule" width="651" height="378"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once module is created, click on the module and you will be directed to the Flow Builder Page where you can create your &lt;code&gt;Rest API&lt;/code&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Create a new Rest API
&lt;/h3&gt;

&lt;p&gt;Look for a button labeled &lt;code&gt;Create Rest API&lt;/code&gt; or &lt;code&gt;+&lt;/code&gt; in the API List space within the interface. This button will initiate the process of creating a new REST API definition.&lt;br&gt;
    - &lt;code&gt;Name&lt;/code&gt; : Name of the API&lt;br&gt;
    - &lt;code&gt;Description&lt;/code&gt;:Short description of the API&lt;br&gt;
    - &lt;code&gt;API Route&lt;/code&gt;: Define the base URL path that will be used to access the API endpoints. This path can include path parameters (indicated by &lt;code&gt;{&amp;lt;param&amp;gt;}&lt;/code&gt;) to capture dynamic values in the URL.&lt;br&gt;&lt;br&gt;
    &lt;strong&gt;Example&lt;/strong&gt;: &lt;code&gt;/users/{userId}&lt;/code&gt; (where &lt;code&gt;{userId}&lt;/code&gt; would be a variable placeholder captured from the request URL).&lt;br&gt;
    - &lt;code&gt;Authentication Method&lt;/code&gt;: If your API requires authentication to access certain or all resources, select the appropriate authentication method. Check on the &lt;a href="https://dev.to/restapi/debuglogs"&gt;Debug section&lt;/a&gt; to know more about authentication. &lt;br&gt;
    - &lt;code&gt;Request Method&lt;/code&gt;: Specify the HTTP method that clients should use to interact with your API.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3rsnzz8nbpxc37yz8vu5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3rsnzz8nbpxc37yz8vu5.png" alt="CreateAPI" width="500" height="620"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Update Workflow to create Spell data in Database
&lt;/h3&gt;

&lt;p&gt;The Worflow builder has 3 basic Blocks such &lt;code&gt;API Endpoint&lt;/code&gt;, &lt;code&gt;Build JSON&lt;/code&gt; and &lt;code&gt;HTTP Response&lt;/code&gt; in the workflow canvas.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuf7ybpm962nxf77cip0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuf7ybpm962nxf77cip0d.png" alt="Workflow builders" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's add &lt;code&gt;Cosmos Create One&lt;/code&gt; block in the workflow to create &lt;code&gt;Spell&lt;/code&gt; data in the database. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Assuming that the database is configured in the Database section of the Project Console.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the "Cosmos Create One" options panel, locate the "container name" field (also referred to as "alias tables"). Enter "spell" as the container name (table name). Then, in the "Record to add" field, input the body data of your request&lt;/p&gt;



&lt;p&gt;The &lt;strong&gt;container name&lt;/strong&gt; field specifies the preferred name for your table (e.g., "spell"). This name will be used as an alias when accessing the table.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0w1dw668cdskwmae2gt9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0w1dw668cdskwmae2gt9.png" alt="Request Body" width="400" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Toggle on &lt;code&gt;Auto create&lt;/code&gt; to automatically create a new instance of the schema with the specified container if it is not already created.&lt;/p&gt;

&lt;p&gt;Now in the &lt;code&gt;HTTP Response&lt;/code&gt; update the &lt;strong&gt;Response Variable&lt;/strong&gt; to &lt;code&gt;{{$createOne.val}}&lt;/code&gt; which is output of the Cosmos Create One.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbf6fez4q66s1y8zt61az.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbf6fez4q66s1y8zt61az.png" alt="CreateOne Spell" width="800" height="459"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;HTTP Response blocks accepts only &lt;strong&gt;JSON&lt;/strong&gt; as response. Make sure your value in response is a JSON.&lt;/p&gt;



&lt;p&gt;Now click on the &lt;code&gt;Deploy&lt;/code&gt; button such that the API is automatically deployed and can be accessed in the specific environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Test the POST method
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Test using Platform
&lt;/h4&gt;

&lt;p&gt;You can test your API by navigating to &lt;code&gt;Logs&lt;/code&gt; section. Click on &lt;code&gt;Debug&lt;/code&gt; button to provide your test data. Select the &lt;code&gt;environment&lt;/code&gt; and provide the necessary body data.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pass you &lt;code&gt;APP-KEY&lt;/code&gt; in the headers (since your authentication is selected as &lt;strong&gt;APP-KEY&lt;/strong&gt;) which can be found in your project settings.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;Make sure to pass &lt;code&gt;id&lt;/code&gt; key in the body data while using &lt;code&gt;POST&lt;/code&gt; method.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgl03k2s3ne39qe8wfzjx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgl03k2s3ne39qe8wfzjx.png" alt="Debug POST request" width="500" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;code&gt;Test API&lt;/code&gt; and you can see the API logs in the page once your API is executed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lmaeu4rcwn4pjj82txa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0lmaeu4rcwn4pjj82txa.png" alt="Debug POST response" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Test using Postman
&lt;/h4&gt;

&lt;p&gt;You can access the API by selecting the specific environment you need. You can find the &lt;strong&gt;API Endpoint&lt;/strong&gt; in the &lt;code&gt;Details&lt;/code&gt; tab.&lt;/p&gt;

&lt;p&gt;Copy the API endpoint and paste in the URL section of the postman. Select method to &lt;code&gt;POST&lt;/code&gt; and nagivate to &lt;code&gt;Headers&lt;/code&gt; and &lt;code&gt;Body&lt;/code&gt; section to pass the required data. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcuiricldd0ba9y4530cd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcuiricldd0ba9y4530cd.png" alt="Postman API Headers" width="800" height="141"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr5gi157c44wzp960mh3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr5gi157c44wzp960mh3n.png" alt="Postman API response" width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can also check the log of this particular request in the &lt;code&gt;Logs&lt;/code&gt; section of the API in the Zeromagic console. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Create new flow to GET Spell Data from DB
&lt;/h3&gt;

&lt;p&gt;Now let's create a new &lt;strong&gt;Rest API&lt;/strong&gt; to fetch Spell data. Click on the &lt;code&gt;+&lt;/code&gt; icon on the RestAPI List section. Enter the details of the API required to fetch the Spell data.&lt;/p&gt;

&lt;p&gt;Add the &lt;code&gt;Cosmos Read Many&lt;/code&gt; block in the workflow to get all the information of the &lt;code&gt;Spells&lt;/code&gt; from the database. Add the &lt;code&gt;Container name&lt;/code&gt;, &lt;code&gt;Sort Key&lt;/code&gt; and &lt;code&gt;Sort Order&lt;/code&gt; in the Options panel.&lt;/p&gt;

&lt;p&gt;Now in the &lt;code&gt;HTTP Response&lt;/code&gt; update the &lt;strong&gt;Response Variable&lt;/strong&gt; to &lt;code&gt;{{$readMany.val}}&lt;/code&gt; which is output of the Cosmos Read Many.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiv4e43ebqgjifztxmz7d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiv4e43ebqgjifztxmz7d.png" alt="Read Many Spells" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on the &lt;code&gt;Deploy&lt;/code&gt; button such that the API is automatically deployed and can be accessed in the specific environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Test the GET method
&lt;/h3&gt;

&lt;p&gt;Navigate to the &lt;code&gt;Logs&lt;/code&gt; section and click on the &lt;code&gt;Debug&lt;/code&gt; button. Provide the necessary &lt;code&gt;Headers&lt;/code&gt; according to the &lt;strong&gt;authentication&lt;/strong&gt; settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7eqambik6oy79cysrkr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7eqambik6oy79cysrkr.png" alt="Debug GET API Request" width="500" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vc9pd63pf0fptwt4eh5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5vc9pd63pf0fptwt4eh5.png" alt="Debug GET API Response" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With &lt;a href="https://zeromagic.cloud/" rel="noopener noreferrer"&gt;Zeromagic&lt;/a&gt;, creating powerful REST APIs is easier than ever. Sign up for &lt;a href="https://console.zeromagic.cloud/" rel="noopener noreferrer"&gt;Zeromagic&lt;/a&gt; and start building your first REST API in minutes. The future of API development is here.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Build SMS API in Minutes with ZeroMagic + Twilio Integration!</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Thu, 19 Sep 2024 15:41:11 +0000</pubDate>
      <link>https://dev.to/ndrohith/build-sms-api-in-minutes-with-zeromagic-twilio-integration-47ho</link>
      <guid>https://dev.to/ndrohith/build-sms-api-in-minutes-with-zeromagic-twilio-integration-47ho</guid>
      <description>&lt;p&gt;Say goodbye to lengthy development cycles! &lt;br&gt;
With &lt;a href="https://zeromagic.cloud/" rel="noopener noreferrer"&gt;ZeroMagic's&lt;/a&gt; intuitive flow builder and Twilio's powerful SMS API, you can create custom SMS workflows in minutes, not days.&lt;/p&gt;

&lt;p&gt;No coding required!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automate SMS notifications, reminders, and alerts&lt;/li&gt;
&lt;li&gt;Integrate with your favorite apps and services&lt;/li&gt;
&lt;li&gt;Scale your SMS workflows with ease&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Get started now and transform your SMS automation game!&lt;/p&gt;

&lt;p&gt;Sign up for ZeroMagic: &lt;a href="https://console.zeromagic.cloud/" rel="noopener noreferrer"&gt;https://console.zeromagic.cloud/&lt;/a&gt;&lt;br&gt;
Learn more about &lt;a href="https://docs.zeromagic.cloud/integrations/twilio" rel="noopener noreferrer"&gt;Zeromagic+Twilio&lt;/a&gt;&lt;br&gt;
Video &lt;a href="https://www.youtube.com/watch?v=IwlE2WMlOhQ" rel="noopener noreferrer"&gt;Reference&lt;/a&gt;&lt;/p&gt;

</description>
      <category>twilio</category>
      <category>zeromagic</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
    <item>
      <title>🚀 Introducing Zeromagic: The Future of AI-Powered API Development</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Wed, 11 Sep 2024 06:25:01 +0000</pubDate>
      <link>https://dev.to/ndrohith/introducing-zeromagic-the-future-of-ai-powered-api-development-24a</link>
      <guid>https://dev.to/ndrohith/introducing-zeromagic-the-future-of-ai-powered-api-development-24a</guid>
      <description>&lt;p&gt;Zeromagic is now live, transforming the way APIs are built and managed for modern applications! 🎉&lt;/p&gt;

&lt;h3&gt;
  
  
  What is &lt;a href="https://zeromagic.cloud/" rel="noopener noreferrer"&gt;Zeromagic&lt;/a&gt;?
&lt;/h3&gt;

&lt;p&gt;Zeromagic is an AI-powered, low-code platform that empowers developers to create RESTful and GraphQL APIs in a fraction of the time. With our advanced AI capabilities, you can generate APIs, data models, and more, allowing you to focus on building robust applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  🌟 Key features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;AI-Powered API Generation: Build RESTful and GraphQL APIs 10x faster with our AI-driven tools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GraphQL Query and Schema Builder: Automatically generate GraphQL queries and schemas based on your database structures.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;REST API Flow Generator: Create REST API functionalities using simple prompts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unified API Management: Seamlessly connect your databases, REST/GraphQL endpoints, and third-party services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fully Managed Platform: Develop, deploy, and scale your microservices independently with ease.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bring Your Own Business Database (BYOD): Integrate your existing databases or use our managed database solutions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 Ready to experience the power of instant API creation? &lt;/p&gt;

&lt;p&gt;Visit us at &lt;a href="https://zeromagic.cloud/" rel="noopener noreferrer"&gt;https://zeromagic.cloud/&lt;/a&gt; and join our growing community of early adopters!&lt;/p&gt;

&lt;p&gt;Docs: &lt;a href="https://docs.zeromagic.cloud/" rel="noopener noreferrer"&gt;https://docs.zeromagic.cloud/&lt;/a&gt;&lt;br&gt;
Blogs: &lt;a href="https://docs.zeromagic.cloud/blog/" rel="noopener noreferrer"&gt;https://docs.zeromagic.cloud/blog/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>zeromagic</category>
      <category>lowcode</category>
      <category>ai</category>
      <category>productivity</category>
    </item>
    <item>
      <title>From Code to Cloud: Deploying Your Python App with Bunnyshell</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Mon, 11 Dec 2023 11:54:17 +0000</pubDate>
      <link>https://dev.to/ndrohith/from-code-to-cloud-deploying-your-python-app-with-bunnyshell-3el7</link>
      <guid>https://dev.to/ndrohith/from-code-to-cloud-deploying-your-python-app-with-bunnyshell-3el7</guid>
      <description>&lt;p&gt;Welcome to the exciting journey of transitioning your python application from code to the cloud! We will take you step-by-step through the process of utilizing Bunnyshell to launch your python application in this blog.&lt;/p&gt;

&lt;p&gt;As an &lt;strong&gt;Environments-as-a-Service&lt;/strong&gt; platform, Bunnyshell enables full-stack environment creation and administration easier for development, staging, and production.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Creating a FastAPI app
&lt;/h3&gt;

&lt;p&gt;In your designated directory, create a new folder named &lt;code&gt;bunny-pyapp&lt;/code&gt;. This will serve as the home for your API project. Make a file called &lt;code&gt;app.py&lt;/code&gt; inside the &lt;code&gt;bunny-pyapp&lt;/code&gt; folder. The main functions of your API will be stored in this file. To prevent cross-origin resource sharing (CORS) issues when utilizing your API, incorporate the CORS Middleware in your &lt;code&gt;app.py&lt;/code&gt;. This is an important step that guarantees your API and other applications communicate with one other seamlessly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi.middleware.cors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CORSMiddleware&lt;/span&gt; 
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uvicorn&lt;/span&gt; 

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 

&lt;span class="n"&gt;origins&lt;/span&gt; &lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;CORSMiddleware&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;allow_origins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;origins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;allow_credentials&lt;/span&gt;&lt;span class="o"&gt;=&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;allow_methods&lt;/span&gt;&lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;allow_headers&lt;/span&gt;&lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;span class="nd"&gt;@app.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&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;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;root&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;message&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;Hello from FastAPI&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; 

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;uvicorn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0.0.0.0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After our script is finished, we'll check to see if the FastAPI is accessible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;python3 app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Point to &lt;a href="http://localhost:8000/"&gt;&lt;code&gt;http://localhost:8000/&lt;/code&gt;&lt;/a&gt; after executing the following command to see the "&lt;em&gt;Hello from Fastapi&lt;/em&gt;" message. A Swagger User Interface (UI) will appear when you route to &lt;a href="http://localhost:8000/docs"&gt;&lt;code&gt;http://localhost:8000/docs&lt;/code&gt;&lt;/a&gt;, assisting in the testing of your endpoints.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Creating a requirements.txt&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To make it easier for us to install all of our packages, we now generate a &lt;code&gt;requirements.txt&lt;/code&gt; file inside the "&lt;em&gt;bunny-app"&lt;/em&gt; folder. You can use the command pip &lt;code&gt;freeze &amp;gt; requirements.txt&lt;/code&gt;, or you can manually add them to the requirements.txt file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fastapi
uvicorn
gunicorn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3. Signing to BunnyShell&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Open the BunnyShell web page by pointing to this &lt;a href="https://www.bunnyshell.com/"&gt;&lt;code&gt;https://www.bunnyshell.com/&lt;/code&gt;&lt;/a&gt; .Once the page is loaded click on to &lt;strong&gt;Log in&lt;/strong&gt; and select &lt;strong&gt;'Environments as a Service'&lt;/strong&gt;.The page will reroute to the BunnyShell Dashboard upon successful login.&lt;/p&gt;

&lt;p&gt;Our deployment process utilizes the power of Kubernetes pods, allowing for efficient scaling and resource management. Docker Compose is a well-known containerization tool, we use its familiar format to make the configuration of these pods easy for developers who are accustomed to it. It is also possible to configure your Kubernetes environment for easy deployment using Helm Charts, which are easily accessible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CiawX1GK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mt5efvcqvfgzwssqc4fi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CiawX1GK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mt5efvcqvfgzwssqc4fi.png" alt="bunnyshell" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. Creating a Dockerfile&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;It's time to build the &lt;code&gt;Dockerfile&lt;/code&gt;, which will serve as the blueprint for creating your bunny-app container image, within your project folder. To shape your container and get it ready for cloud deployment, add the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Specify base image&lt;/span&gt;
&lt;span class="s"&gt;FROM python:3.9&lt;/span&gt;

&lt;span class="c1"&gt;# Set working directory&lt;/span&gt;
&lt;span class="s"&gt;WORKDIR /app&lt;/span&gt;

&lt;span class="c1"&gt;# Install dependencies&lt;/span&gt;
&lt;span class="s"&gt;COPY requirements.txt .&lt;/span&gt;
&lt;span class="s"&gt;RUN pip install -r requirements.txt&lt;/span&gt;

&lt;span class="c1"&gt;# Copy application code&lt;/span&gt;
&lt;span class="s"&gt;COPY . .&lt;/span&gt;

&lt;span class="c1"&gt;# Expose application port&lt;/span&gt;
&lt;span class="s"&gt;EXPOSE &lt;/span&gt;&lt;span class="m"&gt;5000&lt;/span&gt;

&lt;span class="c1"&gt;# Define command to run app&lt;/span&gt;
&lt;span class="s"&gt;CMD ["python3", "app.py"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This Dockerfile provides the foundation for building your bunny-app container image. The application code is copied, the base image is defined, required dependencies are installed, the application's port is exposed, and the command to run when the container starts is specified. Remember to update the Dockerfile with the details of your specific project requirements.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. Creating a Docker compose&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now is the time to construct the &lt;code&gt;docker-compose.yaml&lt;/code&gt; file within your project directory. This vital configuration file orchestrates the deployment and management of your bunny-app within docker containers. You may clearly outline the path your application will take to the cloud by specifying the services, ports, networks, volumes, and other variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.7'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;bunnyapp&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Build the image from the local Dockerfile&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./&lt;/span&gt;

    &lt;span class="c1"&gt;# Expose port 8000 for internal communication &lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;8000:8000&lt;/span&gt;

    &lt;span class="c1"&gt;# Define restart policy to automatically restart the service in case of failures&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;6. Push Code to Github repository&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Create a repository of your choice. In this tutorial I'll be using &lt;code&gt;bunny-app&lt;/code&gt; as repository name. To seamlessly push your code to GitHub, follow these steps in your &lt;code&gt;bunny-pyapp&lt;/code&gt; folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;git init&lt;/span&gt;
&lt;span class="s"&gt;git remote add origin &amp;lt;git_url&amp;gt;&lt;/span&gt;
&lt;span class="s"&gt;git add .&lt;/span&gt;
&lt;span class="s"&gt;git commit -m "first commit"&lt;/span&gt;
&lt;span class="s"&gt;git push -u origin master&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upon successfully pushing your bunny-app code to GitHub, head over to your repository to verify the contents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OHv5Nb92--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ftzxkjzh6x3t4qtcv21d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OHv5Nb92--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ftzxkjzh6x3t4qtcv21d.png" alt="github" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;7. Configuring Deployment&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Locate the "&lt;strong&gt;Create environment"&lt;/strong&gt; button, which is usually located in the interface's right corner. .A pop-up window will appear. Give your environment a name that explains such as &lt;code&gt;bunny-app&lt;/code&gt; or a custom name reflecting your project. Press the &lt;strong&gt;"Create environment"&lt;/strong&gt; button one more time. This will start Bunnyshell creating your customized environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z6hKMB7l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zb4zwxjfz4f13w782jgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z6hKMB7l--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zb4zwxjfz4f13w782jgi.png" alt="create environment" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;strong&gt;"Get Started"&lt;/strong&gt; button and choose with "Docker Compose" or "Package JSON" to start your configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iY6lwX75--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7v31ap823phmvbzpp7wf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iY6lwX75--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7v31ap823phmvbzpp7wf.png" alt="bunnyshell" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select your Git account (e.g., GitHub) and provide the repository name followed by branch and root application path. This allows Bunnyshell to access your code and build the environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3pJ8CZjY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77phor9t9tis27pebba5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3pJ8CZjY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77phor9t9tis27pebba5.png" alt="bunnyshell" width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Based on the organization of your project, Bunnyshell will automatically produce environment components. Inspect these elements carefully, taking note of the ports, volumes, and services. Adjust them as necessary to meet your unique needs.To move on to the last configuration stage, click "Continue".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WuW9Pcm1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hz224gwobswwkpfor9l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WuW9Pcm1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2hz224gwobswwkpfor9l.png" alt="bunnyshell" width="800" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reviewing the entire environment configuration, including resource limitations, environment variables, and health checks, is possible here. Optimize the performance and resource utilization of your bunny-app by making any necessary adjustments. Click "Create Application" to finalize the configuration and build your application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--swqe8BrN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fb5oi3vinb3eryrx1itp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--swqe8BrN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fb5oi3vinb3eryrx1itp.png" alt="bunnyshell" width="800" height="518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note : Check over your context path for your build&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Click the "Deploy" button located in the upper right corner once the project is finished. For deployment, choose the "Bunnyshell Cluster" that is offered by default. Change &lt;strong&gt;"Environment URL"&lt;/strong&gt; to &lt;code&gt;pythonapp&lt;/code&gt; or any other name that better represents your project. The public URL for your deployed application will be this one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Vs-SNY8t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/za1vuj32dj43p0dfa948.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Vs-SNY8t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/za1vuj32dj43p0dfa948.png" alt="bunnyshell" width="718" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the three dots menu beside your environment name and select &lt;code&gt;Pipeline logs&lt;/code&gt; to view the detailed deployment process in real-time. This log will reveal any potential errors or warnings during the build and deployment stages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QrSYmdA0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3gqa03xay9u5pxr17ig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QrSYmdA0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3gqa03xay9u5pxr17ig.png" alt="bunnyshell" width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your application logs will appear simultaneously in the right panel of your Bunnyshell interface. These logs, which contain error messages, debug information, and application activity, provide insightful information about the behavior of your application during runtime.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rbCswyt0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kd5p0dca3noygqqs7va.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rbCswyt0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kd5p0dca3noygqqs7va.png" alt="bunnyshell" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click the "Deployments" option from the dropdown menu beneath your "bunnyapp" name for more in-depth debugging and analysis. This will show the specifics of the Kubernetes deployment, including the logs of each individual container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3SvHUJCg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnme7n5moika02zb50cr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3SvHUJCg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnme7n5moika02zb50cr.png" alt="bunnyshell" width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Access your environment by navigating to the URL &lt;a href="https://bunnyapp-pythonapp.bunnyenv.com/"&gt;&lt;code&gt;https://bunnyapp-pythonapp.bunnyenv.com/&lt;/code&gt;&lt;/a&gt;. You should observe a displayed message on the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2i7uDFgQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbch9a0cstmxyeiqidz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2i7uDFgQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lbch9a0cstmxyeiqidz6.png" alt="bunnyshell" width="737" height="211"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hurray! Your Python app has successfully taken flight on Kubernetes pods with help of Bunnyshell environments.You may run applications created with different technology stacks thanks to Bunnyshell's power, which goes much beyond.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>python</category>
      <category>devops</category>
    </item>
    <item>
      <title>Deploying a Django App with Ingress for Multi-Path Routing on Kubernetes Pods</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Fri, 24 Feb 2023 18:42:56 +0000</pubDate>
      <link>https://dev.to/ndrohith/deploying-a-django-app-with-ingress-for-multi-path-routing-on-kubernetes-pods-1pl9</link>
      <guid>https://dev.to/ndrohith/deploying-a-django-app-with-ingress-for-multi-path-routing-on-kubernetes-pods-1pl9</guid>
      <description>&lt;p&gt;In this blog post, I will guide you through the process of creating a Django app and deploying it in a Kubernetes cluster. Additionally, we will explore how to use an Ingress resource to route traffic to multiple paths on the Kubernetes pods.&lt;/p&gt;

&lt;p&gt;Firstly, we will create a basic Django app and containerize it. Once we have our container image, we will create a deployment and service for our app. The deployment will manage the replicas of our app running in the cluster, and the service will expose our app to the cluster.&lt;/p&gt;

&lt;p&gt;Next, we will create an Ingress resource to route traffic to our app. The Ingress resource will define the routing rules for incoming traffic based on the paths specified in the rules. We will create rules for two paths in our app, '/home' and '/page'.&lt;/p&gt;

&lt;p&gt;Finally, we will deploy the Ingress controller in our cluster. The Ingress controller is a crucial component that will manage the Ingress resources in our cluster and route the incoming traffic to our app.&lt;/p&gt;

&lt;p&gt;With these steps, we will have a fully functional Django app running in a Kubernetes cluster, and incoming traffic will be routed to our app based on the rules defined in the Ingress resource.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Kubernetes?
&lt;/h3&gt;

&lt;p&gt;Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. It provides features such as automatic scaling, rolling updates, self-healing, and service discovery, making it a popular choice for deploying containerized applications in production environments. It can be deployed on-premises, in the cloud, or in a hybrid environment, and integrates with a wide range of other tools and platforms.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Ingress?
&lt;/h3&gt;

&lt;p&gt;Ingress is an API object that provides a way to manage external access to services in a cluster. It allows you to route traffic to different services based on rules defined in the Ingress resource. Ingress can be used to configure load balancing, SSL termination, and virtual host routing. In short, Ingress is a powerful tool for managing external access to applications running in a Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;An Ingress Controller is a component that is responsible for managing and configuring Ingress resources. It reads the rules defined in the Ingress resources and routes the incoming traffic to the appropriate services in the cluster. There are different types of Ingress controllers available, such as NGINX, Traefik, and Istio. Ingress controllers are an essential component in managing external access to services in a Kubernetes cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Django app
&lt;/h3&gt;

&lt;p&gt;Open a terminal or command prompt and navigate to the directory where you want to create your project.&lt;/p&gt;

&lt;p&gt;Run the following command to create a new Django project.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

django-admin startproject &amp;lt;project_name&amp;gt;


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

&lt;/div&gt;
&lt;p&gt;Here I replace my &lt;code&gt;&amp;lt;project_name&amp;gt;&lt;/code&gt; with &lt;code&gt;djangokubernetesproject&lt;/code&gt; .Navigate to the project directory.Run the following command to create a new app.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

python manage.py startapp &amp;lt;app_name&amp;gt;


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

&lt;/div&gt;
&lt;p&gt;Here I replace my &lt;code&gt;&amp;lt;app_name&amp;gt;&lt;/code&gt; with &lt;code&gt;app&lt;/code&gt; .Open the &lt;code&gt;urls.py&lt;/code&gt; file in the project directory and add the following lines.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.contrib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.urls&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;include&lt;/span&gt;

&lt;span class="n"&gt;urlpatterns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;admin/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;site&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;urls&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;app.urls&lt;/span&gt;&lt;span class="sh"&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;Now create an &lt;code&gt;urls.py&lt;/code&gt; file inside your &lt;code&gt;app&lt;/code&gt; directory. Define the URLs for your app.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.contrib&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;admin&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.urls&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;app.views&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;
&lt;span class="n"&gt;urlpatterns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;home/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;home&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;home&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;page/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;page&lt;/span&gt;&lt;span class="sh"&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;Open your &lt;code&gt;views.py&lt;/code&gt; file located in your &lt;code&gt;app&lt;/code&gt; directory and add the following lines.&lt;/p&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;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;django.http&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HttpResponse&lt;/span&gt;
&lt;span class="c1"&gt;# Create your views here.
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;home&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;x_forwarded_for&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;META&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;HTTP_X_FORWARDED_FOR&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x_forwarded_for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x_forwarded_for&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&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;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;META&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;REMOTE_ADDR&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ip address of the client = &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;pod_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;HOSTNAME&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 


    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;h1&amp;gt;Hello World . ip address of the client = &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;h1&amp;gt;Hello World . pod name = &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pod_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;/h1&amp;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;def&lt;/span&gt; &lt;span class="nf"&gt;page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;x_forwarded_for&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;META&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;HTTP_X_FORWARDED_FOR&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x_forwarded_for&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x_forwarded_for&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;'&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;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;META&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;REMOTE_ADDR&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ip address of the client = &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;pod_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;HOSTNAME&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 


    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;HttpResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;h1&amp;gt;Hello World . ip address of the client = &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
        &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;h1&amp;gt;Hello World . pod name = &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pod_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;/h1&amp;gt;&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;p&gt;Now open your &lt;code&gt;settings.py&lt;/code&gt; file and add you app name in the &lt;code&gt;INSTALLED_APPS&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="n"&gt;INSTALLED_APPS&lt;/span&gt; &lt;span class="o"&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;django.contrib.admin&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;django.contrib.auth&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;django.contrib.contenttypes&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;django.contrib.sessions&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;django.contrib.messages&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;django.contrib.staticfiles&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;app&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;p&gt;[Optional] : Open a terminal or command prompt and navigate to the project directory and run the following command to start the development server.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="n"&gt;manage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt; &lt;span class="n"&gt;runserver&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8000&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;This will start the development server, and we can access our app by visiting &lt;a href="http://localhost:8000" rel="noopener noreferrer"&gt;&lt;strong&gt;http://localhost:8000&lt;/strong&gt;&lt;/a&gt; in a web browser.&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating Docker file
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;dockerfile&lt;/code&gt; in your django project directory. Here I am creating my dockerfile inside &lt;code&gt;djangokubernetesproject&lt;/code&gt; directory.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="c1"&gt;# Base image
&lt;/span&gt;&lt;span class="n"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mf"&gt;3.9&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;slim&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;buster&lt;/span&gt;

&lt;span class="c1"&gt;# Set working directory
&lt;/span&gt;&lt;span class="n"&gt;WORKDIR&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;

&lt;span class="c1"&gt;# Copy and install requirements
&lt;/span&gt;&lt;span class="n"&gt;COPY&lt;/span&gt; &lt;span class="n"&gt;requirements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;RUN&lt;/span&gt; &lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="n"&gt;requirements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;

&lt;span class="c1"&gt;# Copy project files
&lt;/span&gt;&lt;span class="n"&gt;COPY&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="c1"&gt;# Set environment variables
&lt;/span&gt;&lt;span class="n"&gt;ENV&lt;/span&gt; &lt;span class="n"&gt;PYTHONDONTWRITEBYTECODE&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;ENV&lt;/span&gt; &lt;span class="n"&gt;PYTHONUNBUFFERED&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="c1"&gt;# Expose port
&lt;/span&gt;&lt;span class="n"&gt;EXPOSE&lt;/span&gt; &lt;span class="mi"&gt;8000&lt;/span&gt;

&lt;span class="c1"&gt;# Run the command to start the server
&lt;/span&gt;&lt;span class="n"&gt;CMD&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;python&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;manage.py&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;runserver&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;0.0.0.0:8000&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;
  
  
  Build a docker image
&lt;/h3&gt;

&lt;p&gt;Once we have created the Dockerfile to configure our Django app, the next step is to build the Docker image and push it to a container registry. To do this, navigate to the project directory in the terminal and run the following commands&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="n"&gt;docker&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;docker_hub_name&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;/&lt;/span&gt;&lt;span class="n"&gt;django&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ingress&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;Here, replace &lt;code&gt;&amp;lt;docker_hub_name&amp;gt;&lt;/code&gt; with your Docker Hub username. For example, if your username is &lt;code&gt;ndrohith09&lt;/code&gt;, the command would be&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="n"&gt;docker&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="n"&gt;ndrohith09&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;django&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ingress&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;This command will build the Docker image with the specified name and tag. Make sure to include the period at the end of the command, as it indicates the build context.&lt;/p&gt;

&lt;p&gt;Once the image is built, it's time to push it to the Docker Hub registry. To do this, run the following command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="n"&gt;docker&lt;/span&gt; &lt;span class="n"&gt;push&lt;/span&gt; &lt;span class="n"&gt;ndrohith09&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;django&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ingress&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;Now that your Docker image is pushed to the Docker Hub registry, you can use it to deploy your Django app on Kubernetes using Ingress.&lt;/p&gt;
&lt;h3&gt;
  
  
  Create kubernetes deployment file
&lt;/h3&gt;

&lt;p&gt;To deploy our Django app on Kubernetes, we need to create a Kubernetes deployment file called &lt;code&gt;django-ingress.yaml&lt;/code&gt; that defines the specifications for our application. In this case, we want to create a deployment that has two paths - &lt;code&gt;/home&lt;/code&gt; and &lt;code&gt;/page&lt;/code&gt;Now we will create a kubernetes deployment file for the django app which has two paths '/home' and '/page'.&lt;/p&gt;

&lt;p&gt;We will use the Docker image that we built and pushed to the Docker Hub container registry in the previous step. Here is an example deployment file that you can use:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

 apiVersion: apps/v1
kind: Deployment
metadata:
  &lt;span class="nc"&gt;name&lt;/span&gt;: home
spec:
  replicas: 2
  selector:
    matchLabels:
      app: home
  template:
    metadata:
      labels:
        app: home
    spec:
      containers:
      &lt;span class="err"&gt;-&lt;/span&gt; &lt;span class="nc"&gt;name&lt;/span&gt;: home
        image: ndrohith09/django-ingress
        ports:
        &lt;span class="err"&gt;-&lt;/span&gt; containerPort: 8000

&lt;span class="err"&gt;---&lt;/span&gt;

apiVersion: v1
kind: Service
metadata:
  &lt;span class="nc"&gt;name&lt;/span&gt;: home-svc 
spec:
  &lt;span class="nc"&gt;type&lt;/span&gt;: LoadBalancer
  ports:
  &lt;span class="err"&gt;-&lt;/span&gt; port: 8000
    targetPort: 8000
    &lt;span class="nc"&gt;protocol&lt;/span&gt;: TCP
    &lt;span class="nc"&gt;name&lt;/span&gt;: http
  selector:
    app: home

&lt;span class="err"&gt;---&lt;/span&gt; 

apiVersion: apps/v1
kind: Deployment
metadata:
  &lt;span class="nc"&gt;name&lt;/span&gt;: page 
spec:
  replicas: 2
  selector:
    matchLabels:
      app: page
  template:
    metadata:
      labels:
        app: page
    spec:
      containers:
      &lt;span class="err"&gt;-&lt;/span&gt; &lt;span class="nc"&gt;name&lt;/span&gt;: page
        image: ndrohith09/django-ingress
        ports:
        &lt;span class="err"&gt;-&lt;/span&gt; containerPort: 8000

&lt;span class="err"&gt;---&lt;/span&gt;

apiVersion: v1
kind: Service
metadata:
  &lt;span class="nc"&gt;name&lt;/span&gt;: page-svc 
spec:
  &lt;span class="nc"&gt;type&lt;/span&gt;: LoadBalancer
  ports:
  &lt;span class="err"&gt;-&lt;/span&gt; port: 8000
    targetPort: 8000
    &lt;span class="nc"&gt;protocol&lt;/span&gt;: TCP
    &lt;span class="nc"&gt;name&lt;/span&gt;: http
  selector:
    app: page


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

&lt;/div&gt;
&lt;p&gt;Thus to configure the Django app with two paths &lt;code&gt;/home&lt;/code&gt; and &lt;code&gt;/page&lt;/code&gt;, we created two Kubernetes deployments, named &lt;code&gt;home&lt;/code&gt; and &lt;code&gt;page&lt;/code&gt;, and two services, named &lt;code&gt;home-svc&lt;/code&gt; and &lt;code&gt;page-svc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After configuring the deployments and services, the next step is to update the &lt;code&gt;django-ingress.yaml&lt;/code&gt; file to configure the ingress. We need to add specific rules and paths for routing the incoming traffic to the appropriate Kubernetes services.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  &lt;span class="nc"&gt;name&lt;/span&gt;: django-ing
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  &lt;span class="nc"&gt;tls&lt;/span&gt;:
  &lt;span class="err"&gt;-&lt;/span&gt; secretName: tls-secret
  rules:
  &lt;span class="err"&gt;-&lt;/span&gt; http:
      paths:
      &lt;span class="err"&gt;-&lt;/span&gt; &lt;span class="nc"&gt;path&lt;/span&gt;: /home
        pathType: Prefix
        backend:
          service:
            &lt;span class="nc"&gt;name&lt;/span&gt;: home-svc
            port:
              number: 8000
  &lt;span class="err"&gt;-&lt;/span&gt; http:
      paths:
      &lt;span class="err"&gt;-&lt;/span&gt; &lt;span class="nc"&gt;path&lt;/span&gt;: /page
        pathType: Prefix
        backend:
          service:
            &lt;span class="nc"&gt;name&lt;/span&gt;: page-svc
            port:
              number: 8000


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

&lt;/div&gt;
&lt;p&gt;To create the Kubernetes services for the Django app, navigate to the project directory in the terminal and execute the relevant commands. These commands will create the services based on the deployment configurations and make them accessible to external traffic through the ingress controller.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

kubectl create -f django-ingress.yaml


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

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Note :&lt;/strong&gt; It is important to understand that the ingress controller does not generate a public IP in local systems. As a result, we need to use cloud providers such as Oracle Cloud Infrastructure (OCI), Amazon Web Services (AWS), Google Cloud Platform (GCP), or Microsoft Azure, among others, that provide Kubernetes services to provision our services and generate a public IP. This will enable us to access our Django app from anywhere on the internet.&lt;/p&gt;
&lt;h3&gt;
  
  
  Deployment in Cloud platforms
&lt;/h3&gt;

&lt;p&gt;Here, we will be deploying our Django app on a cloud platform, specifically on the &lt;code&gt;Oracle Kubernetes Cluster (OKE)&lt;/code&gt;. First, you need to create an Oracle Cloud account and navigate to the Kubernetes Clusters (OKE) page to create your own Kubernetes cluster. You can refer to the official documentation for creating a Kubernetes cluster in Oracle Cloud.&lt;/p&gt;

&lt;p&gt;Docs: &lt;a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingclusterusingoke_topic-Using_the_Console_to_create_a_Quick_Cluster_with_Default_Settings.htm" rel="noopener noreferrer"&gt;Creating a Kubernetes Cluster&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After creating the Kubernetes cluster, you can access it using either the &lt;code&gt;cloud shell access&lt;/code&gt; or &lt;code&gt;local access&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Docs: &lt;a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengdownloadkubeconfigfile.htm" rel="noopener noreferrer"&gt;Setting Up Cluster Access&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have access to your Kubernetes cluster, the next step is to set up the Ingress controller on the cluster. Ingress controllers are not a part of the Kubernetes core components, and there are different Ingress controllers available to choose from.&lt;/p&gt;

&lt;p&gt;For Oracle Kubernetes Engine (OKE), the recommended Ingress controller is the Oracle Cloud Infrastructure (OCI) Load Balancing Ingress Controller. This controller is specifically designed for OKE and integrates with the Oracle Cloud Infrastructure Load Balancing service to provide a fully-managed, scalable and secure ingress solution for your cluster.&lt;/p&gt;

&lt;p&gt;You can follow the official documentation to set up the OCI Load Balancing Ingress Controller on your OKE cluster.&lt;/p&gt;

&lt;p&gt;Docs: &lt;a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengsettingupingresscontroller.htm" rel="noopener noreferrer"&gt;Setting Up an Ingress Controller on a Cluster&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the Ingress controller is installed and configured, you can proceed with creating and applying your Ingress resource YAML file (&lt;code&gt;django-ingress.yaml)&lt;/code&gt; to configure routing to your Django app's services.&lt;/p&gt;

&lt;p&gt;Note that the process for setting up an Ingress controller may differ depending on the cloud provider or infrastructure you are using. Make sure to refer to the relevant documentation for your platform to ensure proper setup and configuration of your Ingress controller.&lt;/p&gt;

&lt;p&gt;To apply the services in the cluster, navigate to the project directory and use the following command to apply the &lt;code&gt;django-ingress.yaml&lt;/code&gt; file&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

kubectl apply -f django-ingress.yaml


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

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://media.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%2Fv04bjwjwjdike6lg40sa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fv04bjwjwjdike6lg40sa.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will create the necessary resources in the cluster, including the ingress controller and the defined routes for our Django app. To get more details about the resources in your Kubernetes cluster, you can use the following command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

kubectl get &lt;span class="ss"&gt;all&lt;/span&gt;


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

&lt;/div&gt;
&lt;p&gt;This command will list all the resources in your cluster, including deployments, pods, services, and ingress. You can use this command to verify that your Django app is up and running, and that your ingress rules have been properly configured.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fhrd6bjkpjge9t5dmh9ey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fhrd6bjkpjge9t5dmh9ey.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the resources are created, we can check the status of the ingress controller by running the following command&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

kubectl get ingress


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

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://media.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%2Fvldyl04cwla1f88z1t8p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fvldyl04cwla1f88z1t8p.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will display the details of the ingress resources created in the cluster, including the host, path, and backend service details. If the external IP address is not automatically generated by the cloud provider, we can check the status of the ingress resources by running the following command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

kubectl describe ingress


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

&lt;/div&gt;
&lt;p&gt;&lt;a href="https://media.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%2F9p8n870vs52bo0ti0h2q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F9p8n870vs52bo0ti0h2q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will provide more detailed information about the ingress controller, including the IP address and any errors or warnings encountered during configuration.&lt;/p&gt;

&lt;p&gt;With our ingress controller and services configured, we can now access our Django app using the external IP address provided by the ingress controller. You can retrieve the external IP address by running the command &lt;code&gt;kubectl get ingress&lt;/code&gt; in your terminal. Once you have the external IP address, you can access your Django app by navigating to the defined paths in the browser, such as &lt;code&gt;http://&amp;lt;external_ip_address&amp;gt;/home&lt;/code&gt; and &lt;code&gt;http://&amp;lt;external_ip_address&amp;gt;/page&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To access the Django app, we can navigate to the defined paths '/home' and '/page' in the browser using the external IP provided by the ingress controller &lt;code&gt;144.24.133.172&lt;/code&gt;. This will route the requests to the respective Kubernetes pods and display the output on the browser.&lt;/p&gt;

&lt;p&gt;To access the &lt;code&gt;/home&lt;/code&gt; path of the Django app, you can use the following URL: &lt;a href="http://144.24.133.172/page" rel="noopener noreferrer"&gt;&lt;code&gt;http://144.24.133.172/home&lt;/code&gt;&lt;/a&gt;. This should display the HTML response that corresponds to the &lt;code&gt;/home&lt;/code&gt; path that we defined earlier in our ingress configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F8bni8nsj24pl9m3awrp6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F8bni8nsj24pl9m3awrp6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly To access the &lt;code&gt;/page&lt;/code&gt; path of the Django app, you can use the following URL: &lt;a href="http://144.24.133.172/page" rel="noopener noreferrer"&gt;&lt;code&gt;http://144.24.133.172/page&lt;/code&gt;&lt;/a&gt;. This should display the HTML response that corresponds to the &lt;code&gt;/page&lt;/code&gt; path that we defined earlier in our ingress configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fwdquzy9ah5yumnll5y8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fwdquzy9ah5yumnll5y8q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you have gained a good understanding of how to create a Django app and use Ingress to route traffic to multiple paths on Kubernetes pods.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/ndrohith09" rel="noopener noreferrer"&gt;
        ndrohith09
      &lt;/a&gt; / &lt;a href="https://github.com/ndrohith09/django-ingress" rel="noopener noreferrer"&gt;
        django-ingress
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Thank You!&lt;br&gt;&lt;br&gt;
Disclaimer: This article was created with the help of AI.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>nginx</category>
      <category>docker</category>
    </item>
    <item>
      <title>AI Based Art and Caption Generator and Color Restoration</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Wed, 14 Dec 2022 14:04:53 +0000</pubDate>
      <link>https://dev.to/ndrohith/ai-based-art-and-caption-generator-and-color-restoration-1bph</link>
      <guid>https://dev.to/ndrohith/ai-based-art-and-caption-generator-and-color-restoration-1bph</guid>
      <description>&lt;p&gt;Hello everyone! This is one of my hackathon projects, and it can perform colour restoration, produce art from text, and generate captions for photographs.&lt;/p&gt;

&lt;p&gt;With the rise of AI, it becomes easier for artists to express themselves without having to go through the process of creating an artwork. Artificial intelligence has the ability to consistently learn from past experiences and adapt to changes, making it the perfect candidate for eventually generating meaningful captions. Most vintage films are practically black and white, yet these films are not preferred by the current generation. We must convert them to coloured films so that old good films can be colourized for improved viewing. The conversion procedure can be expensive, but with the help of AI, the cost can be cut significantly.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Deploy FastAPI application on Digital Ocean with Nginx and Gunicorn</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Fri, 09 Dec 2022 05:10:49 +0000</pubDate>
      <link>https://dev.to/ndrohith/deploy-fastapi-application-on-digital-ocean-with-nginx-and-gunicorn-2lnk</link>
      <guid>https://dev.to/ndrohith/deploy-fastapi-application-on-digital-ocean-with-nginx-and-gunicorn-2lnk</guid>
      <description>&lt;p&gt;In this blog, I will explain to you how to develop a FastAPI application and deploy it in Digital Ocean using Nginx and Gunicorn. Now let's start by creating a basic FastAPI application.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Creating FastAPI application
&lt;/h3&gt;

&lt;p&gt;Create a folder called &lt;code&gt;fast-api-ocean&lt;/code&gt; in your specified directory. Inside the directory create &lt;code&gt;api.py&lt;/code&gt; file which contains the fastapi code. To avoid any CORS problems when using the API, we will additionally integrate CORS Middleware.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi.middleware.cors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CORSMiddleware&lt;/span&gt; 
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uvicorn&lt;/span&gt; 

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 

&lt;span class="n"&gt;origins&lt;/span&gt; &lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;CORSMiddleware&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;allow_origins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;origins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;allow_credentials&lt;/span&gt;&lt;span class="o"&gt;=&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;allow_methods&lt;/span&gt;&lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;allow_headers&lt;/span&gt;&lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;span class="nd"&gt;@app.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&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;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;root&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;message&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;Hello from Fastapi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; 

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;uvicorn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0.0.0.0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;When our script is complete, we will test to see if the FastAPI is working.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;python3 api.py


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

&lt;/div&gt;

&lt;p&gt;After running the following command point to the &lt;code&gt;http://localhost:8000/&lt;/code&gt; such that you find the message &lt;em&gt;"Hello from Fastapi"&lt;/em&gt; displayed. On routing to &lt;code&gt;http://localhost:8000/docs&lt;/code&gt; a swagger UI will be provided which helps to test your endpoints.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Creating requirements.txt&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now we create a &lt;code&gt;requirements.txt&lt;/code&gt; such that we can install all of our packages at ease. You can either add them manually in &lt;code&gt;requirements.txt&lt;/code&gt; file or else follow the command &lt;code&gt;pip freeze &amp;gt; requirements.txt&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

fastapi
uvicorn
gunicorn


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;3. Creating Digital Ocean droplet&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Sign in to your digital ocean account. Now on the top section click on &lt;code&gt;Create&lt;/code&gt; and select &lt;code&gt;Droplets&lt;/code&gt; .I have opted &lt;code&gt;Banglore&lt;/code&gt; server region.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fiiy4h5kmzhkw5nw9sw97.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fiiy4h5kmzhkw5nw9sw97.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now choose an image for the server. I am going with &lt;code&gt;Ubuntu 22.10 x64&lt;/code&gt; image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F099fpqd2sbfexvhjehjp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F099fpqd2sbfexvhjehjp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can select any of the CPU options. I chose 1GB RAM with 25GB NVMe SSD.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fgwzcfvn0yjqc95whf6lt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fgwzcfvn0yjqc95whf6lt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;Authentication Method&lt;/code&gt; I have selected &lt;code&gt;SSH Key&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Ffmzp9oc9os7prmr97ox1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Ffmzp9oc9os7prmr97ox1.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can go with other options based on your droplet customization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Frn3q216pc3ewqsocqw9s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Frn3q216pc3ewqsocqw9s.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on &lt;code&gt;Create Droplet&lt;/code&gt; such that your droplet will be created. You can find your droplets in the Droplets section.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;4. Accessing Droplet via SSH&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;You can access your droplet either by clicking on the&lt;code&gt;Console&lt;/code&gt; which is present on the top right corner. The other best and simple way is to access the droplet in you local machine using SSH. Copy the &lt;code&gt;ipv4&lt;/code&gt; address of your droplet.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fgmtqo8u1r4akibg8oux9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fgmtqo8u1r4akibg8oux9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can access your droplet by executing the following command in your terminal. Here I am accessing as a root user.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="err"&gt;$&lt;/span&gt; ssh root@165.22.217.59


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;5. Copy files via SCP&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now we need to copy the folder which contains our code file such as &lt;code&gt;api.py&lt;/code&gt; , &lt;code&gt;requirements.txt&lt;/code&gt; from our local machine to the remote server. This can be achieved with the help of SCP. Open your terminal in your &lt;code&gt;local-machine&lt;/code&gt; and navigate to your folder and execute the SCP command.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="err"&gt;$&lt;/span&gt; scp -r fast-api-ocean root@165.22.217.59:/root


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

&lt;/div&gt;

&lt;p&gt;Here I am copying my &lt;code&gt;fast-api-ocean&lt;/code&gt; folder to the &lt;code&gt;root&lt;/code&gt; of the remote server. Once copying is done you can navigate to &lt;code&gt;/root/fast-api-ocean&lt;/code&gt; path and find you files.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Create a virtual environment
&lt;/h3&gt;

&lt;p&gt;In the &lt;code&gt;fast-api-ocean&lt;/code&gt; directory lets create a virtual environment using &lt;code&gt;virtualenv&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

root@165.22.217.59:~/fast-api-ocean# pip install virtualenv
root@165.22.217.59:~/fast-api-ocean# virtualenv venv
root@165.22.217.59:~/fast-api-ocean# source venv/bin/activate


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

&lt;/div&gt;
&lt;h3&gt;
  
  
  7. Nginx Configuration
&lt;/h3&gt;

&lt;p&gt;To server the application over HTTP we have to make an Nginx config for our application. You can add any name to your app. Here I have specified as &lt;code&gt;fast-api-ocean&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="err"&gt;(&lt;/span&gt;venv) root@165.22.217.59:~# sudo nano /etc/nginx/sites-available/fast-api-ocean


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

&lt;/div&gt;

&lt;p&gt;Add the following lines to the file. Place your IP domain in the server_name. My IP domain is &lt;code&gt;165.22.217.59&lt;/code&gt; .&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="nc"&gt;server&lt;/span&gt;{
       &lt;span class="nc"&gt;server_name&lt;/span&gt; 165.22.217.59; 
       &lt;span class="ss"&gt;location&lt;/span&gt; / {
           &lt;span class="nc"&gt;include&lt;/span&gt; proxy_params;
           proxy_pass http://127.0.0.1:8000;
       &lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Now press &lt;code&gt;ctrl+s&lt;/code&gt; to save the file and &lt;code&gt;ctrl+x&lt;/code&gt; to exit. Then we create a symbolic link to this config file in the &lt;code&gt;/etc/nginx/sites-enabled&lt;/code&gt; directory.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="err"&gt;(&lt;/span&gt;venv) root@165.22.217.59:~# sudo ln -s /etc/nginx/sites-available/fast-api-ocean /etc/nginx/sites-enabled/


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

&lt;/div&gt;

&lt;p&gt;Then we restart the Nginx service.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="err"&gt;(&lt;/span&gt;venv) root@165.22.217.59:~# sudo systemctl restart nginx.service


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

&lt;/div&gt;

&lt;p&gt;Now we can start our uvicorn server to check if our application is working or not.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="err"&gt;(&lt;/span&gt;venv) root@165.22.217.59:~# gunicorn -w 4 -k uvicorn.workers.UvicornWorker api:app


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

&lt;/div&gt;

&lt;p&gt;We should be able to access the URL and view our application from a browser now that our application is serving and the proxy server is set up correctly.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Configure ASGI Server
&lt;/h3&gt;

&lt;p&gt;Now that our application is deployed and configured properly one last thing to do is to create a service for the Gunicorn server so that it is constantly running and it automatically begins when the server is rebooted. Systemd will be used to build the service.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="err"&gt;(&lt;/span&gt;venv) root@165.22.217.59:~# deactivate 
root@165.22.217.59:~# sudo nano /etc/systemd/system/fastapiocean.service


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

&lt;/div&gt;

&lt;p&gt;In this new file we will add the following lines&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

&lt;span class="err"&gt;[&lt;/span&gt;Unit]
&lt;span class="nc"&gt;Description&lt;/span&gt;=Gunicorn instance to serve MyApp
After=network.target

&lt;span class="err"&gt;[&lt;/span&gt;Service]
&lt;span class="nc"&gt;User&lt;/span&gt;=&amp;lt;username&amp;gt;
&lt;span class="nc"&gt;Group&lt;/span&gt;=www-data
WorkingDirectory=/root/fast-api-ocean
Environment="PATH=/root/fast-api-ocean/venv/bin"
ExecStart=/root/fast-api-ocean/venv/bin/gunicorn -w 4 -k uvicorn.workers.UvicornWorker api:app

&lt;span class="err"&gt;[&lt;/span&gt;Install]
WantedBy=multi-user.target


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

&lt;/div&gt;

&lt;p&gt;Change the configurations to suit your system, save the file, and then close it.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;

root@165.22.217.59:~# sudo systemctl start fastapiocean.service


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

&lt;/div&gt;

&lt;p&gt;Our new service will be launched at this point, and our ASGI server will be running in the background.&lt;/p&gt;

&lt;p&gt;Hurray! It's done. Now you can navigate to your &lt;code&gt;IP-domain&lt;/code&gt; . Here in my case its &lt;code&gt;http://165.22.217.59/&lt;/code&gt; . Now you can find your FastAPI application running in the background in your droplets &lt;code&gt;IP-domain&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;I hope you find this blog helpful. Thank You.&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>digitalocean</category>
      <category>devops</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Deploy a containerised Fast API application in Digital Ocean</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Tue, 06 Dec 2022 16:12:18 +0000</pubDate>
      <link>https://dev.to/ndrohith/deploy-a-containerised-fast-api-application-in-digital-ocean-25ik</link>
      <guid>https://dev.to/ndrohith/deploy-a-containerised-fast-api-application-in-digital-ocean-25ik</guid>
      <description>&lt;p&gt;In this blog, I will explain to you how to develop a FastAPI application, containerize it, and deploy it in Digital Ocean. Now let's start by creating a basic FastAPI application.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Creating FastAPI application
&lt;/h3&gt;

&lt;p&gt;Create a folder called &lt;code&gt;fast-api-ocean&lt;/code&gt; in your specified directory. Inside the directory create &lt;code&gt;api.py&lt;/code&gt; file which contains the fastapi code. To avoid any CORS problems when using the API, we will additionally integrate CORS Middleware.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi.middleware.cors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CORSMiddleware&lt;/span&gt; 
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uvicorn&lt;/span&gt; 

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 

&lt;span class="n"&gt;origins&lt;/span&gt; &lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add_middleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;CORSMiddleware&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;allow_origins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;origins&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;allow_credentials&lt;/span&gt;&lt;span class="o"&gt;=&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;allow_methods&lt;/span&gt;&lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;allow_headers&lt;/span&gt;&lt;span class="o"&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;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;span class="nd"&gt;@app.get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&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;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;root&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;message&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;Hello from Fastapi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; 

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;uvicorn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0.0.0.0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When our script is complete, we will test to see if the FastAPI is working.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 api.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the following command point to the &lt;code&gt;http://localhost:8000/&lt;/code&gt; such that you find the message &lt;em&gt;"Hello from Fastapi"&lt;/em&gt; displayed. On routing to &lt;code&gt;http://localhost:8000/docs&lt;/code&gt; a swagger UI will be provided which helps to test your endpoints.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Creating requirements.txt
&lt;/h3&gt;

&lt;p&gt;Now we create a &lt;code&gt;requirements.txt&lt;/code&gt; such that we can install all of our packages at ease. You can either add them manually in &lt;code&gt;requirements.txt&lt;/code&gt; file or else follow the command &lt;code&gt;pip freeze &amp;gt; requirements.txt&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;fastapi
uvicorn
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Creating a docker file
&lt;/h3&gt;

&lt;p&gt;Let's now create a &lt;code&gt;dockerfile&lt;/code&gt; which is used to build Docker Images. It is a simple text file that consists of a set of instructions or commands that is executed by an automated build process in steps from top to bottom.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;FROM python:3.10

WORKDIR /src

ADD ./ /src

RUN pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--upgrade&lt;/span&gt; pip
RUN pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--no-cache-dir&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt

EXPOSE 8000 

CMD &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"python"&lt;/span&gt;, &lt;span class="s2"&gt;"api.py"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now our &lt;code&gt;dockerfile&lt;/code&gt; is ready and we can create our image by using the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; fast-ocean &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the image has been created, use the following command to execute it as a container. Now point to &lt;code&gt;http://0.0.0.0:8000/&lt;/code&gt; such that you can find your application running there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 8000:8000 fast-ocean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run the container in detached mode (in the background) by adding a tag &lt;code&gt;-d&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8000:8000 fast-ocean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Creating Digital Ocean droplet
&lt;/h3&gt;

&lt;p&gt;Sign in to your digital ocean account. Now on the top section click on &lt;code&gt;Create&lt;/code&gt; and select &lt;code&gt;Droplets&lt;/code&gt; .I have opted &lt;code&gt;Banglore&lt;/code&gt; server region.&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%2Fqjspc70fs1cg43q2kroc.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%2Fqjspc70fs1cg43q2kroc.png" alt="droplet" width="800" height="319"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now choose an image for the server. I am going with &lt;code&gt;Ubuntu 22.10 x64&lt;/code&gt; image.&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%2Fnhxmvlum2s5y9j84m1bj.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%2Fnhxmvlum2s5y9j84m1bj.png" alt="server image" width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can select any of the CPU options. I chose 1GB RAM with 25GB NVMe SSD.&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%2Fvqbrefmj3p3wvg7by5wp.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%2Fvqbrefmj3p3wvg7by5wp.png" alt="CPU Options" width="800" height="171"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;Authentication Method&lt;/code&gt; I have selected &lt;code&gt;SSH Key&lt;/code&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%2Fvnl70omtunszfoqzogh0.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%2Fvnl70omtunszfoqzogh0.png" alt="Auth" width="800" height="105"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can go with other options based on your droplet customization.&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%2Ft159vt66mlt7opkweicy.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%2Ft159vt66mlt7opkweicy.png" alt="options" width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on &lt;code&gt;Create Droplet&lt;/code&gt; such that your droplet will be created. You can find your droplets in the Droplets section.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Accessing Droplet via SSH
&lt;/h3&gt;

&lt;p&gt;You can access your droplet either by clicking on the&lt;code&gt;Console&lt;/code&gt; which is present on the top right corner. The other best and simple way is to access the droplet in you local machine using SSH. Copy the &lt;code&gt;ipv4&lt;/code&gt; address of your droplet.&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1670338744145%2FgC6BBKxqW.png%2520align%3D" 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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1670338744145%2FgC6BBKxqW.png%2520align%3D" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can access your droplet by executing the following command in your terminal. Here I am accessing as a root user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh root@165.22.217.59
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you access your droplet type update all the packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Installing Docker in Digital Ocean Droplet
&lt;/h3&gt;

&lt;p&gt;You can install docker in your droplet either by using &lt;code&gt;snap&lt;/code&gt; or &lt;code&gt;apt&lt;/code&gt; in your droplet terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;snap &lt;span class="nb"&gt;install &lt;/span&gt;docker
    &lt;span class="c"&gt;# (or)&lt;/span&gt;
apt  &lt;span class="nb"&gt;install &lt;/span&gt;docker.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once your docker installation is done you can verify it by using the version command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. Copy files via SCP
&lt;/h3&gt;

&lt;p&gt;Now we need to copy the folder which contains our code file such as &lt;code&gt;api.py&lt;/code&gt; , &lt;code&gt;requirements.txt&lt;/code&gt; and &lt;code&gt;dockerfile&lt;/code&gt; from our local machine to the remote server. This can be achieved with the help of SCP. Open your terminal in your &lt;code&gt;local-machine&lt;/code&gt; and navigate to your folder and execute the SCP command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scp &lt;span class="nt"&gt;-r&lt;/span&gt; fast-api-ocean root@165.22.217.59:/root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here I am copying my &lt;code&gt;fast-api-ocean&lt;/code&gt; folder to the &lt;code&gt;root&lt;/code&gt; of the remote server. Once copying is done you can navigate to &lt;code&gt;/root/fast-api-ocean&lt;/code&gt; path and find you files.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Building a docker image and running it in detached mode
&lt;/h3&gt;

&lt;p&gt;As we installed docker in our Digital Ocean droplet now we can build the image with the help of the &lt;code&gt;Dockerfile&lt;/code&gt; present in the &lt;code&gt;fast-api-ocean&lt;/code&gt; folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; fast-ocean-droplet &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's run the container in detached mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8000:8000 fast-ocean-droplet
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hurray! It's done. Now you can navigate to &lt;code&gt;port 80&lt;/code&gt; of your &lt;code&gt;IP-domain&lt;/code&gt; . Here in my case its &lt;code&gt;http://165.22.217.59/&lt;/code&gt; . Now you can find your FastAPI container running in the background in your droplets &lt;code&gt;IP-domain&lt;/code&gt; . The &lt;code&gt;Dockerfile&lt;/code&gt; can be modified to suit your needs.&lt;/p&gt;

&lt;p&gt;I hope you find this blog helpful. Thank You&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>api</category>
    </item>
    <item>
      <title>Bluetooth Controlled Robot</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Sun, 07 Aug 2022 15:14:00 +0000</pubDate>
      <link>https://dev.to/ndrohith/bluetooth-controlled-robot-14a5</link>
      <guid>https://dev.to/ndrohith/bluetooth-controlled-robot-14a5</guid>
      <description>&lt;p&gt;In this blog, I will show you how to build a bluetooth controlled robot with HC-05 bluetooth module and an Arduino microcontroller. You can use any bluetooth mobile app available in playstore to connect you mobile to bluetooth module. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F33xvqgcwgac5uelfbui5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F33xvqgcwgac5uelfbui5.png" alt="bluetooth controlled robot.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Components required
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Arduino UNO&lt;/li&gt;
&lt;li&gt;HC-05&lt;/li&gt;
&lt;li&gt;Gear Motors&lt;/li&gt;
&lt;li&gt;IC L293D&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Arduino UNO
&lt;/h3&gt;

&lt;p&gt;Arduino is an opensource electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor , a finger on a button , or a twitter message - and turn it into an output - activating a motor , turning on a LED , publishing something online. To do so use the Arduino programming language (based on wiring) and the Arduino Software (IDE) based on processing.&lt;/p&gt;

&lt;h3&gt;
  
  
  HC-05 Bluetooth module
&lt;/h3&gt;

&lt;p&gt;The HC-05 is a popular wireless module that can add two-way (full-duplex) functionality to your projects. You can use this module to communicate between two microcontrollers, such as Arduino, or to communicate with any Bluetooth-enabled device, such as a phone or laptop. Many Android applications are already available, making this process much easier.&lt;/p&gt;

&lt;h3&gt;
  
  
  Gear Motors
&lt;/h3&gt;

&lt;p&gt;It is a DC motor with a gear box for decreasing the speed and increasing the torque and power . This type of motors is commonly used for robotic applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  IC L293D
&lt;/h3&gt;

&lt;p&gt;IC L293D is a dual H-bridge motor driver integrated circuit that can drive current of up to 600mA with voltage range of 4.5 to 36 volts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F7q2akeqqyw7xwbae8r1o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F7q2akeqqyw7xwbae8r1o.png" alt="l293d"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In that Bluetooth app, tapping &lt;code&gt;0&lt;/code&gt; turns the motor off, while pressing &lt;code&gt;1&lt;/code&gt; causes the motor 1 to spin right. Similar to this, when tapping &lt;code&gt;2&lt;/code&gt; ,  &lt;code&gt;3&lt;/code&gt; and &lt;code&gt;4&lt;/code&gt;, the motors 1 turns left , the motor 2 turn right and the motor 2 spins left, respectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;motorPin1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;motorPin2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;motorPin3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;motorPin4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;flag&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9600&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;available&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;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;{&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&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;}&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sc"&gt;'0'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&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;{&lt;/span&gt;
      &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MOTOR:off"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;flag&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="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sc"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&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;{&lt;/span&gt;
      &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MOTOR1:right"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;flag&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="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sc"&gt;'2'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&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;{&lt;/span&gt;
      &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MOTOR1:left"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;flag&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="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sc"&gt;'3'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&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;{&lt;/span&gt;
      &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MOTOR2:right"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;flag&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="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sc"&gt;'4'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&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;{&lt;/span&gt;
      &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MOTOR2:LEFT"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;flag&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="p"&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;



</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>arduino</category>
    </item>
    <item>
      <title>Black Line Follower with Arduino</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Sat, 30 Jul 2022 09:07:33 +0000</pubDate>
      <link>https://dev.to/ndrohith/black-line-follower-with-arduino-4mje</link>
      <guid>https://dev.to/ndrohith/black-line-follower-with-arduino-4mje</guid>
      <description>&lt;p&gt;In this blog, I will show you how to build a black line follower robot with an Arduino microcontroller and IR Sensors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F42qeabkn22jkn1m04e4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F42qeabkn22jkn1m04e4m.png" alt="line follower"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Components required
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Arduino UNO &lt;/li&gt;
&lt;li&gt;IR Sensor &lt;/li&gt;
&lt;li&gt;Gear Motors &lt;/li&gt;
&lt;li&gt;IC L293D&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Arduino UNO
&lt;/h2&gt;

&lt;p&gt;Arduino is an opensource electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor , a finger on a button , or a twitter message - and turn it into an output - activating a motor , turning on a LED , publishing something online. To do so use the Arduino programming language (based on wiring) and the Arduino Software (IDE) based on processing.&lt;/p&gt;

&lt;h2&gt;
  
  
  IR Sensor
&lt;/h2&gt;

&lt;p&gt;An infrared sensor is an electronic device that emits and/or detects infrared radiation in order to sense some aspects of its surroundings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gear Motors
&lt;/h2&gt;

&lt;p&gt;It is a DC motor with a gear box for decreasing the speed and increasing the torque and power . This type of motors is commonly used for robotic applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  IC L293D
&lt;/h2&gt;

&lt;p&gt;IC L293D is a dual H-bridge motor driver integrated circuit that can drive current of up to 600mA with voltage range of 4.5 to 36 volts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fewol61cqyxmj3oinbz9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fewol61cqyxmj3oinbz9y.png" alt="l293d"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;leftir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;rightir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;leftmotor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;leftmotor1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;rightmotor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;rightmotor1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9600&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;INPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;INPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"FORWARD"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"LEFT"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"RIGHT"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;leftmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rightmotor1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"BACKWARD"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>beginners</category>
      <category>programming</category>
      <category>arduino</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Analog Input using Arduino</title>
      <dc:creator>Rohith ND</dc:creator>
      <pubDate>Wed, 20 Jul 2022 09:37:29 +0000</pubDate>
      <link>https://dev.to/ndrohith/analog-input-using-arduino-1k1a</link>
      <guid>https://dev.to/ndrohith/analog-input-using-arduino-1k1a</guid>
      <description>&lt;p&gt;In this blog, I will show you how to create an analog input using Arduino.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fWrKDH9---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu2vooocs7vjsc19zxq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fWrKDH9---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uu2vooocs7vjsc19zxq1.png" alt="analog input" width="880" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Components required
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Arduino UNO &lt;/li&gt;
&lt;li&gt;Potentiometer&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Arduino UNO
&lt;/h2&gt;

&lt;p&gt;Arduino is an opensource electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor , a finger on a button , or a twitter message - and turn it into an output - activating a motor , turning on a LED , publishing something online. To do so use the Arduino programming language (based on wiring) and the Arduino Software (IDE) based on processing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Potentiometer
&lt;/h2&gt;

&lt;p&gt;A three-terminal resistor with a sliding or revolving contact that creates a variable voltage divider is called a potentiometer. It functions as a variable resistor or rheostat if only the wiper and one end of the connector are used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;sensorPin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;A0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;// select the input pin for the potentiometer&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;ledPin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;sensorValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;sensorValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;analogRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sensorPin&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sensorValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ledPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sensorValue&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;



</description>
      <category>arduino</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
