<?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: Harsh Vardhan Goswami</title>
    <description>The latest articles on DEV Community by Harsh Vardhan Goswami (@electronlab).</description>
    <link>https://dev.to/electronlab</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%2F202304%2Fcfd38b1c-e163-4012-938c-bfff13c8b3ed.jpeg</url>
      <title>DEV Community: Harsh Vardhan Goswami</title>
      <link>https://dev.to/electronlab</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/electronlab"/>
    <language>en</language>
    <item>
      <title>How i built a COVID-19 News Restful API</title>
      <dc:creator>Harsh Vardhan Goswami</dc:creator>
      <pubDate>Sat, 04 Apr 2020 05:14:29 +0000</pubDate>
      <link>https://dev.to/electronlab/how-i-built-a-covid-19-news-restful-api-12ia</link>
      <guid>https://dev.to/electronlab/how-i-built-a-covid-19-news-restful-api-12ia</guid>
      <description>&lt;p&gt;Hello beautiful people this is me harsh. I created a COVID-19 news Restful API using python flask and beautiful soap. I named it CORONEWS-19 API and it also got its own website and documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why i built it?
&lt;/h2&gt;

&lt;p&gt;I created a website called gocorona.wtf with my friend Roshan Chokshi and in our website we have a news section where we display the COVID-19 news so we were using newsapi and that api has a limit of hits per user and all that free and paid service shit so i just came up with a idea that why not create our own api for delivering COVID-19 news. So i just opened Atom(Text Edito) i personally use and started building it and now i will explain how.&lt;/p&gt;

&lt;h2&gt;
  
  
  How i built it?
&lt;/h2&gt;

&lt;p&gt;So this CORONEWS-19 API is built on top of flask(python framework for making web apps) and beautiful soup and now you guys be thinking that from where you getting news so thats where beautiful soup comes in. Building of this API includes few stages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Gathering the data.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;2.Structuring the data.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;3.Providing the data as response to request.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lets talk about how i got the news data.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, for this task i have used beautiful soup to scrap news websites to gather the news it's kind a illegal thing to scrap any website without permission but hey we can give it a shot. From every website i have gathered news article title, feature image, link to the article. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now it's time to structure the data we have got from beautiful soup.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, as i have mentioned above that i have scraped news website so its time to arrange the data in a proper manner so for this i took a empty list and then i appended every news article i got from beautiful soup in a dictionary format with title,img,link of the article the output was something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"news"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"img"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"https://raw.githubusercontent.com/theuitown/COROAPIWEB/master/20200328_183732_0000.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"https://www.newsnation.in/world/news/trump-expands-role-of-us-army-in-fight-against-coronavirus-pandemic-257699.html"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"President Trump Expands Role Of US Army In Fight Against Coronavirus Pandemic"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"img"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"https://raw.githubusercontent.com/theuitown/COROAPIWEB/master/20200328_183732_0000.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"link"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"https://news.abplive.com/videos/news/india-china-observes-national-mourning-day-for-covid-19-victims-1189266"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"China observes national mourning day for COVID-19 victims"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we got the data now its time to ready it for the users of the API.&lt;/p&gt;

&lt;p&gt;For this task i choose flask and i created a python function which has all the code inside which at last returns the list of news articles and then i initialized a flask app and set an route '/' to a class which gives a list in form of json using flask function called jsonify. Those who wanna read the code here you go.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&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;route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&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;articles&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;'title'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'img'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s"&gt;'link'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;link&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;news&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is how i made this API and now its time to host this api somewhere so that people can use it in their projects. So i choosed heroku for this task because it supports server based web apps and also its free to some extent. &lt;/p&gt;

&lt;p&gt;You can see the response of this API by visiting this link &lt;a href="https://coronews.iamharsh.design/"&gt;Click Here&lt;/a&gt;.&lt;br&gt;
You can read the small documentation of this api here &lt;a href="https://coronews.iamharsh.design/"&gt;https://coronews.iamharsh.design/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading this post ❤️. I really appreciate it man and you can also read my own blog website &lt;a href="https://electron.iamharsh.design/"&gt;Electron Blog&lt;/a&gt;. With that being said this is me harsh and i am signing out and i will catch you guys in my next one.&lt;/p&gt;

</description>
      <category>python</category>
      <category>computerscience</category>
      <category>webdev</category>
    </item>
    <item>
      <title>GIT CLI CRASH COURSE</title>
      <dc:creator>Harsh Vardhan Goswami</dc:creator>
      <pubDate>Sat, 07 Mar 2020 14:16:31 +0000</pubDate>
      <link>https://dev.to/electronlab/git-cli-crash-course-11p9</link>
      <guid>https://dev.to/electronlab/git-cli-crash-course-11p9</guid>
      <description>&lt;p&gt;Hey folks, out there we all know about github and it is basically a git hosting site so now you must be wondering what is git? In simple words Git is a distributed version control system for tracking changes in source code during software development. Itis designed for coordinating work among programmers, but it can be used to track changes in any set of files.&lt;/p&gt;

&lt;p&gt;Hey you can also read this full article on my blog website, i will be grateful to you if you visit it once 😊.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://electron.iamharsh.design/2020/03/06/git-cli-crash-course.html"&gt;My Blog..&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;So now we must step further diving into git commands (GUI guys please stay away from this post).&lt;/p&gt;

&lt;h3&gt;
  
  
  1.git init
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Utility&lt;/strong&gt;: To initialise a git repo on your local machine in your current project directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.git clone 
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Utility&lt;/strong&gt;: This command is use to clone a git repo on to your local machine this could be your own repo hosted on GitHub or any other repo by some other cool developer just like me. Here you just have to replace  with the url of that repo you want to clone or download.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.git config
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Utility&lt;/strong&gt;: To config the git on your machine (mandatory) .&lt;br&gt;
&lt;strong&gt;Syntax&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config --global user.name "theuitown"
git config --global user.email "electronlabsdev@gmail.com"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  4.git add
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Utility&lt;/strong&gt;: To save or add the changes you have made to the working directory this will not really take effect until you commit the changes.&lt;br&gt;
&lt;strong&gt;Syntax:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"git add &amp;lt;file_name&amp;gt;" or "git add ." (to add all the files to repo)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  5.git status
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Utility&lt;/strong&gt;: To check the status of the repo like what all changes you have made and what is added to repo and what not.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://electron.iamharsh.design/2020/03/06/git-cli-crash-course.html"&gt;Read More..&lt;/a&gt;
&lt;/h2&gt;

</description>
      <category>git</category>
      <category>cli</category>
      <category>github</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Create A Dark/Light Theme Switch with CSS/JS</title>
      <dc:creator>Harsh Vardhan Goswami</dc:creator>
      <pubDate>Sun, 05 Jan 2020 12:28:31 +0000</pubDate>
      <link>https://dev.to/electronlab/integrate-theme-switcher-into-your-website-3o9d</link>
      <guid>https://dev.to/electronlab/integrate-theme-switcher-into-your-website-3o9d</guid>
      <description>&lt;p&gt;Hey, folks out there so you must have seen dark mode options in most of the websites and if you haven't seen any of it then you can take a look at my portfolio website &lt;a href="https://iamharsh.design/"&gt;https://iamharsh.design/&lt;/a&gt; . Now if you have already done that then you are eligible to think of implementing it in your websites without a much do let's get our hand dirty with some code. Wait I have a way to do that what you have to do is just open your code in any of your favorite text editor and follow my steps.&lt;/p&gt;

&lt;p&gt;First thing first we will write some HTML shit to add a theme switcher button so that users can see where to click to change the theme of the website lets do it open your HTML file and add the following code into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="theme-switch-wrapper"&amp;gt;
       &amp;lt;label class="theme-switch" for="checkbox"&amp;gt;
    &amp;lt;input type="checkbox" id="checkbox" /&amp;gt;
    &amp;lt;div class="fas fa-moon moonboi fa-2x"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/label&amp;gt;
  &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here we have added a moon icon using fontawesome library its free you can use it which acts as a theme switcher its upto your choice what you wanna use inplace of moon.&lt;/p&gt;

&lt;p&gt;Now it might look ugly because it is only the skeleton so to make it handsome just open your CSS file and add the following code it's optional🖖(no it's not)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:root {
    --font-color: #424242;
    --bg-color: #fff;
}

[data-theme="dark"] {
    --font-color: #fff;
    --bg-color: #161625;
}

/*slider switch css */

  .theme-switch {
    display: inline-block;
    height: 34px;
    top:2rem;
    position: relative;
    width: 60px;
  }

  .theme-switch input {
    display:none;
  }

  .moonboi{font-size: 1rem;transition: .4s;}
  .moonboi::before{transition: .4s;}

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



&lt;p&gt;Here in the above CSS shit, we have created two classes of color variables one is for light mode and one is for dark mode now after adding this what you have to do is add the variable name instead of color code wherever it is needed. Like say if you have to add color to text then you can use this like color: var(--font-color);&lt;/p&gt;

&lt;p&gt;So here comes the main part the implementation of theme switch based on user's choice so in order to achieve it just add the following lines into your javascript code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
const currentTheme = localStorage.getItem('theme');

if (currentTheme) {
    document.documentElement.setAttribute('data-theme', currentTheme);

    if (currentTheme === 'dark') {
        toggleSwitch.checked = true;
    }
}

function switchTheme(e) {
    if (e.target.checked) {
        document.documentElement.setAttribute('data-theme', 'dark');
        localStorage.setItem('theme', 'dark');
    }
    else {        document.documentElement.setAttribute('data-theme', 'light');
          localStorage.setItem('theme', 'light');
    }    
}

toggleSwitch.addEventListener('change', switchTheme, false);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After merging the shitty code written above into your code you can test your website and you will see a moon icon in order to test it just click on it and you will see that theme of the whole website will change with a beautiful transition.&lt;/p&gt;

&lt;h1&gt;
  
  
  Poor Man's Dark Mode
&lt;/h1&gt;

&lt;p&gt;and if you are a lazy person like me then you can just add two lines of shit into css to get dark mode&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
@media (prefers-color-scheme: light) {
    body {
              background:#fff;
          color: #424242;
    }
}

@media (prefers-color-scheme: dark) {
    body {
        background: #161625;
                color:#fff;
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now if you are using the poor man's dark mode method then add this into css and don't give any color or background color property to any element otherwise this method will not work otherwise choice is yours 🤣.&lt;/p&gt;

&lt;h2&gt;
  
  
  Back to the point
&lt;/h2&gt;

&lt;p&gt;This is pretty much it so I must take leave now if you have any issue adding it to your website you can leave a comment or if you want to have a chat with me you can DM me on Instagram at any time i have nothing to do :).&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>TEXT GLITCH REVEAL ANIMATION..</title>
      <dc:creator>Harsh Vardhan Goswami</dc:creator>
      <pubDate>Fri, 09 Aug 2019 15:23:57 +0000</pubDate>
      <link>https://dev.to/electronlab/text-glitch-reveal-animation-54lh</link>
      <guid>https://dev.to/electronlab/text-glitch-reveal-animation-54lh</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/harsh-vardhan/embed/byrmpB?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
  </channel>
</rss>
