<?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>Forem: Andrew Sverdrup</title>
    <description>The latest articles on Forem by Andrew Sverdrup (@andrewsverdrup).</description>
    <link>https://forem.com/andrewsverdrup</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%2F73702%2Fb9c1a6e1-924a-4198-bd9c-51c836372f01.png</url>
      <title>Forem: Andrew Sverdrup</title>
      <link>https://forem.com/andrewsverdrup</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/andrewsverdrup"/>
    <language>en</language>
    <item>
      <title>Building Your First React Website</title>
      <dc:creator>Andrew Sverdrup</dc:creator>
      <pubDate>Wed, 17 Jul 2019 14:03:35 +0000</pubDate>
      <link>https://forem.com/nexttech/building-your-first-react-website-c5c</link>
      <guid>https://forem.com/nexttech/building-your-first-react-website-c5c</guid>
      <description>&lt;p&gt;React is one of the most popular web frameworks out there. It has been growing steadily in popularity for years, passing Angular for the first time in the &lt;a href="https://insights.stackoverflow.com/survey/2019#technology-_-web-frameworks"&gt;2019 Stack Overflow developer survey&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This post will show you how to create your own React website in just a few minutes. If you're interested in learning more after completing this tutorial, checkout the &lt;a href="https://c.next.tech/2EUAVlp"&gt;Beginning React&lt;/a&gt; course I just created on Next Tech to further improve your React skills.&lt;/p&gt;

&lt;p&gt;For now, let's dive right into building a website with React!&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;To complete these steps you'll need to have the Node Package Manager (npm) installed.  If you don't have it installed yet, head on over to &lt;a href="https://www.npmjs.com/get-npm"&gt;https://www.npmjs.com/get-npm&lt;/a&gt; to download and install npm.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This will also install &lt;code&gt;npx&lt;/code&gt; which we'll use to run &lt;code&gt;create-react-app&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Create React App
&lt;/h2&gt;

&lt;p&gt;Create React App is an excellent way to quickly get a React website up and running. Create React App was created by Facebook (the same company that created React!). In their docs, they describe it as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Create React App is an officially supported way to create single-page React applications. It offers a modern build setup with no configuration.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Knowing that &lt;strong&gt;Create React App is supported by the creators of React&lt;/strong&gt; is a huge plus. Let's use it to get started with our website!&lt;/p&gt;

&lt;p&gt;Run the following command to create your site:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-app hello-react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note that it may take a couple minutes for this command to complete.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Viewing the React website
&lt;/h2&gt;

&lt;p&gt;Next, run the following commands to start the React development server:&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="nb"&gt;cd &lt;/span&gt;hello-react
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point a browser tab should open showing your React site. If it doesn't, visit &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt; in your favorite browser to see your React site!&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating the site
&lt;/h2&gt;

&lt;p&gt;Now, let's make a change to update the site. Open the &lt;code&gt;hello-react/src/App.js&lt;/code&gt; file, then replace the following line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Edit &amp;lt;code&amp;gt;src/App.js&amp;lt;/code&amp;gt; and save to reload.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;My first React website!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you open the web page again you'll see that it updated without you having to refresh the page! Live reloading is one of the awesome features that Create React App configures for you.&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%2F384xygh36kqylllrt4j3.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%2F384xygh36kqylllrt4j3.png" alt="Create React App Website" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a React Component
&lt;/h2&gt;

&lt;p&gt;Next, we'll create a new React component. First, create a folder in the &lt;code&gt;src&lt;/code&gt; folder named &lt;code&gt;components&lt;/code&gt;. Then create a file called &lt;code&gt;HomepageImage.js&lt;/code&gt; in the &lt;code&gt;src/components&lt;/code&gt; folder. This file will hold our new homepage image component.&lt;/p&gt;

&lt;p&gt;We'll create this component by adding the following code to the &lt;code&gt;HomepageImage.js&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;HomepageImage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://cdn.filestackcontent.com/XYrHCaFGRSaq0EPKY1S6&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;650&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;'Image of Golden Gate Bridge'&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Then, in &lt;code&gt;App.js&lt;/code&gt;, replace&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;logo&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App-logo"&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"logo"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;HomepageImage&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need to import the component at the top of &lt;code&gt;App.js&lt;/code&gt; by adding the following code to the top of the file:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Since we removed the image of the React logo, you can then remove this import for the logo as well:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The final &lt;code&gt;App.js&lt;/code&gt; file should look like this:&lt;br&gt;
&lt;/p&gt;

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

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;header&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App-header"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;HomepageImage&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          My first React website!
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;a&lt;/span&gt;
          &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"App-link"&lt;/span&gt;
          &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://reactjs.org"&lt;/span&gt;
          &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_blank"&lt;/span&gt;
          &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"noopener noreferrer"&lt;/span&gt;
        &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
          Learn React
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;header&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Now, open &lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt; again in your browser. If everything is working, you should see the following page:&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%2F2c4qeniczw0l2mxrllyz.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%2F2c4qeniczw0l2mxrllyz.png" alt="Image of finished website" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations on creating your first website using React 🎉!&lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;This tutorial was a quick introduction to creating web pages with React. If you want to gain a better understanding of React so you can build awesome sites using it, checkout &lt;a href="https://c.next.tech/2EUAVlp"&gt;the course&lt;/a&gt; I just released that teaches React!&lt;/p&gt;

&lt;p&gt;Have you built a site with React?  Feel free to share your URL or a link to your project on GitHub in the comments below to show it off!&lt;/p&gt;

&lt;p&gt;Thanks for reading,&lt;/p&gt;

&lt;p&gt;Andrew, Software Engineer @ Next Tech&lt;/p&gt;




&lt;p&gt;Special thanks to &lt;a href="https://unsplash.com/@mvdheuvel?utm_medium=referral&amp;amp;utm_campaign=photographer-credit&amp;amp;utm_content=creditBadge"&gt;Maarten van den Heuvel&lt;/a&gt; for taking the photo of the Golden Gate Bridge used in this post!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to use the OpenWeatherMap API with Python</title>
      <dc:creator>Andrew Sverdrup</dc:creator>
      <pubDate>Wed, 22 May 2019 01:51:25 +0000</pubDate>
      <link>https://forem.com/nexttech/how-to-use-the-openweathermap-api-with-python-ge8</link>
      <guid>https://forem.com/nexttech/how-to-use-the-openweathermap-api-with-python-ge8</guid>
      <description>&lt;p&gt;OpenWeatherMap is an online service that provides access weather data, including current weather data, forecasts, and historical data. Developers can use their API (application programming interface) to make requests and incorporate the returned data into their website or app.&lt;/p&gt;

&lt;p&gt;In this video you'll learn how to get the temperature, wind speed, humidity, and weather status using the Python OpenWeatherMap library, which provides an interface to the OpenWeatherMap API.&lt;/p&gt;

&lt;p&gt;You'll get to use the Python programming language, a real application programming interface (API), and (if you'd like) an online coding environment!&lt;/p&gt;

&lt;p&gt;We'd love to hear what you think of the video, and if you have any ideas for other videos you'd like to see. We'll be making many more in the weeks to come!&lt;/p&gt;

&lt;p&gt;Now, without further ado, let's code!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/cXTD9ePA8RI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>python</category>
      <category>api</category>
      <category>learning</category>
    </item>
    <item>
      <title>How to use the OpenWeatherMap API with Python</title>
      <dc:creator>Andrew Sverdrup</dc:creator>
      <pubDate>Wed, 06 Feb 2019 16:53:10 +0000</pubDate>
      <link>https://forem.com/nexttech/how-to-use-the-openweathermap-api-with-python-5dkg</link>
      <guid>https://forem.com/nexttech/how-to-use-the-openweathermap-api-with-python-5dkg</guid>
      <description>&lt;p&gt;In this article we’ll explore the powerful OpenWeatherMap API, which allows you to access and use weather data in your programs. It can be used to display information such as the temperature, wind, and humidity, for the current weather and for the forecasted weather.&lt;/p&gt;

&lt;p&gt;We’ll use the Python programming language and an awesome library called Python OpenWeatherMap (PyOWM) to make it easier to use the OpenWeatherMap API in Python.&lt;/p&gt;

&lt;p&gt;This article is based on an interactive course I released on Next XYZ. The course has Python and the PyOWM library preinstalled and lets you use both directly from your browser. If you want to learn even more about PyOWM , you can &lt;a href="https://c.next.tech/2DgPvC0"&gt;check out the course&lt;/a&gt; and get started for free!&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Your Environment
&lt;/h2&gt;

&lt;p&gt;To run the code snippets in this article you’ll need to have Python and the &lt;code&gt;pyowm&lt;/code&gt; library installed (install instructions for &lt;code&gt;pyowm&lt;/code&gt; can be found &lt;a href="https://github.com/csparpa/pyowm"&gt;here&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Once you have this installed, you can open up a Python shell from your command line (usually using &lt;code&gt;python&lt;/code&gt; or &lt;code&gt;python3&lt;/code&gt;, depending on which version of Python you're using) and use it to run the commands below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting your OpenWeatherMap API Key
&lt;/h2&gt;

&lt;p&gt;Once you have your environment setup, the next step is to get your free API key from the &lt;a href="https://openweathermap.org/"&gt;OpenWeatherMap website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After you’ve signed up on OpenWeatherMap’s website, you’ll see this at the top of the page:&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%2Fthshzxtrmypaweue6trl.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%2Fthshzxtrmypaweue6trl.png" width="800" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on "API keys" and you’ll see the API key.&lt;/p&gt;

&lt;p&gt;When you work with the the examples below, you’ll need to replace &lt;code&gt;&amp;lt;api_key&amp;gt;&lt;/code&gt; with this API key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Weather Conditions
&lt;/h2&gt;

&lt;p&gt;Now that you have your API key, let’s check the weather! First we’ll start by checking if there are any clouds in the five-day forecast for Los Angeles. Here’s the code to do that:&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;import&lt;/span&gt; &lt;span class="n"&gt;pyowm&lt;/span&gt;
&lt;span class="n"&gt;owm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pyowm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OWM&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;api_key&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# TODO: Replace &amp;lt;api_key&amp;gt; with your API key
&lt;/span&gt;&lt;span class="n"&gt;la&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;owm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;three_hours_forecast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Los Angeles, US&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="n"&gt;la&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;will_have_clouds&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break this down. We start by importing the &lt;code&gt;pyowm&lt;/code&gt; library, then we authenticate using an API key. The authenticated connection to the API is stored in the &lt;code&gt;owm&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;Next we use the &lt;code&gt;three_hours_forecast()&lt;/code&gt; method to get the forecast for a specified location (in this case, Los Angeles) and store it in the la variable. Note that the &lt;code&gt;three_hours_forecast()&lt;/code&gt; method returns a five-day forecast with weather data sampled every three hours.&lt;/p&gt;

&lt;p&gt;Now that we have the weather object, we can call the &lt;code&gt;will_have_clouds()&lt;/code&gt; method on it to check if there will be clouds! Within the &lt;code&gt;pyowm&lt;/code&gt; library, this will check the weather at each three-hour interval and if any weather sample indicates there will be clouds, the method will return true, otherwise it will return false.&lt;/p&gt;

&lt;p&gt;We can also use PyOWM to see if it will rain, be foggy, or check for other common weather conditions. OpenWeatherMap has data from all around the world as well. For example, let’s take a look at the weather in London:&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;import&lt;/span&gt; &lt;span class="n"&gt;pyowm&lt;/span&gt;
&lt;span class="n"&gt;owm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pyowm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OWM&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;api_key&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# TODO: Replace &amp;lt;api_key&amp;gt; with your API key
&lt;/span&gt;&lt;span class="n"&gt;london&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;owm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;three_hours_forecast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;London, GB&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="n"&gt;london&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;will_have_rain&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="n"&gt;london&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;will_have_fog&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Awesome! With just a few lines of code you can get and display some amazing information in your program.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current Temperature
&lt;/h2&gt;

&lt;p&gt;Now let’s take a look at how to get the current temperature:&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;import&lt;/span&gt; &lt;span class="n"&gt;pyowm&lt;/span&gt;
&lt;span class="n"&gt;owm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pyowm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OWM&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;api_key&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# TODO: Replace &amp;lt;api_key&amp;gt; with your API key
&lt;/span&gt;&lt;span class="n"&gt;sf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;owm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;weather_at_place&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;San Francisco, US&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;weather&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sf&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_weather&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="n"&gt;weather&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_temperature&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;fahrenheit&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;temp&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;As you might guess from the use of &lt;code&gt;'fahrenheit'&lt;/code&gt; in the above code, you can also request the data in Celsius by passing &lt;code&gt;'celsius'&lt;/code&gt; to the &lt;code&gt;get_temperature()&lt;/code&gt; method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sunrise and Sunset Times
&lt;/h2&gt;

&lt;p&gt;Another cool thing you can do with PyOWM is request and display the sunrise and sunset times. The &lt;code&gt;get_sunrise_time()&lt;/code&gt; and &lt;code&gt;get_sunset_time()&lt;/code&gt; methods can be called to get this info. There is a catch when using these methods though- they return the time in unix time by default (e.g., &lt;strong&gt;1542800608&lt;/strong&gt;). Passing the &lt;code&gt;timeformat='iso'&lt;/code&gt; parameter converts the time to a more human-readable format (e.g., &lt;strong&gt;2018–11–21 21:16:54+00&lt;/strong&gt;). Also, the times are in the GMT timezone (in the Next XYZ course we cover how to convert the times to a specific timezone).&lt;/p&gt;

&lt;p&gt;Here’s an example of getting the sunrise and sunset times:&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;import&lt;/span&gt; &lt;span class="n"&gt;pyowm&lt;/span&gt;
&lt;span class="n"&gt;owm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pyowm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OWM&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;api_key&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# TODO: Replace &amp;lt;api_key&amp;gt; with your API key
&lt;/span&gt;&lt;span class="n"&gt;boston&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;owm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;weather_at_place&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Boston, US&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;weather&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boston&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_weather&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="n"&gt;weather&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_sunrise_time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timeformat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;iso&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# Prints time in GMT timezone
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;weather&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_sunset_time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timeformat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;iso&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# Prints time in GMT timezone
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;If you enjoyed this post and want to learn more about using Python OpenWeatherMap to access weather data, check out the &lt;a href="https://c.next.tech/2DgPvC0"&gt;course on Next XYZ&lt;/a&gt;, which goes more in-depth into how to use PyOWM. It also includes interactive tasks and quizzes which will help you master the material in the course. By the end of it you’ll have created a weather GUI just like the image below!&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%2Fqdyjprr8ekn5iak3bjoi.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%2Fqdyjprr8ekn5iak3bjoi.png" width="501" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have any questions or comments? Just leave a note below!&lt;/p&gt;

&lt;p&gt;Thanks for reading, and happy coding!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>api</category>
      <category>python</category>
      <category>learntocode</category>
    </item>
    <item>
      <title>ActionChat to spread positive energy and motivation!</title>
      <dc:creator>Andrew Sverdrup</dc:creator>
      <pubDate>Fri, 25 May 2018 23:58:56 +0000</pubDate>
      <link>https://forem.com/andrewsverdrup/actionchat-to-spread-positive-energy-and-motivation-mio</link>
      <guid>https://forem.com/andrewsverdrup/actionchat-to-spread-positive-energy-and-motivation-mio</guid>
      <description>&lt;h1&gt;
  
  
  What I built
&lt;/h1&gt;

&lt;p&gt;ActionChat is an iOS and Android chat app that specializes in spreading positive energy!  Its easy to use.  Simply select a time to chat and at that time your chat window will open for five minutes.  Spread and receive as many positive messages as possible in those five minutes.&lt;/p&gt;

&lt;p&gt;The intended use for this app is to set it for a time in the morning just after you wake up.  Then you get access to the chat for five minutes and get flooded with positive energy to help you start your day off right!  So what are you waiting for?  Download ActionChat today!  Special shoutout to &lt;a href="https://pusher.com/"&gt;Pusher&lt;/a&gt; for powering the chat functionality with their awesome &lt;a href="https://pusher.com/channels"&gt;Channels API&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo Link
&lt;/h2&gt;

&lt;p&gt;This app is published on &lt;a href="https://expo.io/"&gt;Expo&lt;/a&gt;.  Download their &lt;a href="https://expo.io/tools#client"&gt;client app&lt;/a&gt; to run any expo app on your phone.  The link to ActiveChat is: &lt;a href="https://expo.io/@andrewsverdrup/active-chat"&gt;https://expo.io/@andrewsverdrup/active-chat&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Link to Code
&lt;/h2&gt;

&lt;p&gt;The code is located on GitHub here: &lt;a href="https://github.com/AndrewSverdrup/ActionChat"&gt;https://github.com/AndrewSverdrup/ActionChat&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Tech stack
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://pusher.com/channels"&gt;Pusher Channels API&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Powers the chat functionality&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://facebook.github.io/react-native/"&gt;React-Native&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Mobile app framework&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://expo.io/"&gt;Expo&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Mobile app SDK to simplify cross-platform app creation&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/react-community/create-react-native-app"&gt;Create React Native App&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Boilerplate to get started with React-Native and Expo&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cloud.google.com/functions/"&gt;Google Cloud Functions&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;For Pusher Channels Authentication endpoint (b/c serverless is cool)&lt;/li&gt;
&lt;li&gt;My cloud function code can be found here: &lt;a href="https://github.com/AndrewSverdrup/ActionChatCloudFunction"&gt;https://github.com/AndrewSverdrup/ActionChatCloudFunction&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>pushercontest</category>
      <category>reactnative</category>
      <category>expo</category>
      <category>javascript</category>
    </item>
    <item>
      <title>ActionChat to start your day off right!</title>
      <dc:creator>Andrew Sverdrup</dc:creator>
      <pubDate>Sun, 20 May 2018 06:48:45 +0000</pubDate>
      <link>https://forem.com/andrewsverdrup/actionchat-to-start-your-day-off-right-3ldj</link>
      <guid>https://forem.com/andrewsverdrup/actionchat-to-start-your-day-off-right-3ldj</guid>
      <description>

&lt;p&gt;Announcing ActionChat, a mobile app where you are surrounded by like-minded people who inspire each other to make the most of the day!&lt;/p&gt;

&lt;p&gt;I often hear that the key to a productive day is having a solid morning routine.  When people talk about morning routines, they usually mention exercising, a shower, meditation, a cup of coffee, and reviewing the day's tasks.  This is a great way to start the day, but many people struggle to get into their routine.  The goal of this app is to allow people to chat with each other first thing in the morning to motivate each other to take control of their day!&lt;/p&gt;

&lt;p&gt;I think &lt;a href="https://pusher.com/channels"&gt;Pusher Channels&lt;/a&gt; will be a great API for this app.  I've done some tutorials with Firebase in the past, but I'm always on the lookout for the best tools out there.  I'm looking forward to trying out Pusher Channels and making an awesome app! &lt;/p&gt;

&lt;h2&gt;
  
  
  Tech stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pusher.com/channels"&gt;Pusher Channels API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://facebook.github.io/react-native/"&gt;React-Native&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://expo.io/"&gt;Expo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/react-community/create-react-native-app"&gt;Create React Native App&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay tuned for updates!&lt;/p&gt;

&lt;p&gt;Thanks for reading,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Andrew&lt;/li&gt;
&lt;/ul&gt;


</description>
      <category>pushercontest</category>
      <category>reactnative</category>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
