<?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: Roshan Sharma</title>
    <description>The latest articles on DEV Community by Roshan Sharma (@roshnet).</description>
    <link>https://dev.to/roshnet</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%2F200871%2F8d4ae77b-bc1b-46e3-a8f2-30d05bcb6753.jpeg</url>
      <title>DEV Community: Roshan Sharma</title>
      <link>https://dev.to/roshnet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/roshnet"/>
    <language>en</language>
    <item>
      <title>How do you dive into large open source projects?</title>
      <dc:creator>Roshan Sharma</dc:creator>
      <pubDate>Fri, 24 Apr 2020 12:50:50 +0000</pubDate>
      <link>https://dev.to/roshnet/how-do-you-dive-in-to-large-open-source-projects-32hi</link>
      <guid>https://dev.to/roshnet/how-do-you-dive-in-to-large-open-source-projects-32hi</guid>
      <description>&lt;p&gt;I recently got started with Golang. It's a pretty awesome language.&lt;/p&gt;

&lt;p&gt;I decided to contribute to &lt;a href="https://github.com/gohugoio/hugo"&gt;Hugo&lt;/a&gt;, but I eventually became afraid to start. It felt like I'll take forever to acquaint myself with a code base that large, let alone finding bugs and solving issues.&lt;/p&gt;

&lt;p&gt;On the other hand, I've also heard people say that you do not need to know the entire code base to start contributing. I've started to think if that depends on the nature of the project perhaps.&lt;/p&gt;

&lt;p&gt;I would appreciate if anyone has advice on what should be the preferred mindset, and/or their experience in such a situation.&lt;/p&gt;

&lt;p&gt;Much thanks!&lt;/p&gt;

</description>
      <category>opensource</category>
    </item>
    <item>
      <title>The baffling thing about trailing slashes</title>
      <dc:creator>Roshan Sharma</dc:creator>
      <pubDate>Thu, 23 Jan 2020 16:41:50 +0000</pubDate>
      <link>https://dev.to/roshnet/the-baffling-thing-about-trailing-slashes-1kb3</link>
      <guid>https://dev.to/roshnet/the-baffling-thing-about-trailing-slashes-1kb3</guid>
      <description>&lt;p&gt;If someone asked the old-me, “What's the big deal about trailing slashes?”, my answer would likely be – “ah, they make URLs look cool. That's it!”.&lt;/p&gt;

&lt;p&gt;However, I recently met with an accident of running into an issue which changed my view for trailing slashes forever.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Avoid trailing slashes at all costs, unless you have a thing for exhausting yourself on small issues.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are times when you decide, “Okay, I can finish this in an hour, and then move on to other things”. Everything happens like you planned, except for the time barrier – you sometimes tend to take a little longer than that.&lt;/p&gt;

&lt;p&gt;I wasted 6 hours on what could've been solved by removing a single character from a small group of files.&lt;/p&gt;

&lt;p&gt;Now, the question is – what the heck was it?&lt;/p&gt;

&lt;p&gt;I had made an API in Falcon (a Python web framework), of course with routes registered with trailing slashes. There were 8 endpoints. So far, I managed to debug all errors I had encountered, thanks to the awesome documentation.&lt;/p&gt;

&lt;p&gt;This was the case until one fine day, my Insomnia client started giving me “405 Method Not Allowed” responses on endpoints which had very well been tested before. I struggled with debugging this behavior, completely discarding the idea that a trailing slash could be the source of all problems.&lt;/p&gt;

&lt;p&gt;What I was doing was writing logic for a PUT request to a resource, which showed me the 405 thing on testing.&lt;/p&gt;

&lt;p&gt;After reading related forums online, I started to think that I had found the culprit. People there were still unsure about which practice was better (i.e. to-trailing-slash or to not-trailing-slash). They were good at explaining things, but shared their personal preferences, expressing uncertainity about various ideology behind the REST architecture.&lt;/p&gt;

&lt;p&gt;Any way, I removed all the trailing slashes, tested each endpoint, and yay! It worked.&lt;/p&gt;

&lt;p&gt;The underlying problem was my structuring of routes. I had multiple routes under “/posts/”, which were -&lt;br&gt;
    – “/posts/{username}” to show all posts by {username}&lt;br&gt;
    – “/posts/edit?a={author}&amp;amp;p={post}“, to edit the specified post&lt;br&gt;
    – and others...&lt;/p&gt;

&lt;h2&gt;
  
  
  What went wrong
&lt;/h2&gt;

&lt;p&gt;I was doing it all wrong. It was only at the end that I was able to figure it out:&lt;/p&gt;

&lt;p&gt;In the app, I was calling the API from “/posts/edit/?a={...}&amp;amp;p={...}“, which was wrong in the app but worked when done from the Insomnia client.&lt;/p&gt;

&lt;p&gt;I found that it didn't matter whether I added a trailing slash when registering the route in code. In essence, app.add_route('/posts/edit/') worked the same as app.add_route('/posts/edit'). However, calling assuming the latter works fine in most cases.&lt;/p&gt;

&lt;p&gt;The expected behaviour was observed when “edit/?...” was changed to “edit?...”.&lt;/p&gt;

&lt;h1&gt;
  
  
  Summary
&lt;/h1&gt;

&lt;p&gt;PUT /posts/edit/?a=1&amp;amp;b=2 is completely different from PUT /posts/edit?a=1&amp;amp;b=2&lt;/p&gt;

&lt;p&gt;In Flask, I found that if you registered a route as @app.route('/login'), and typed in the browser's address bar “/login/”, it would throw you a 404.&lt;/p&gt;

&lt;p&gt;But, if you do @app.route('/login/'), it works whether or not the trailing slash is injected or not.&lt;/p&gt;

&lt;p&gt;I hope spending 3 minutes reading this might save someone 3 hours.&lt;/p&gt;

&lt;p&gt;If you are familiar with some of this trouble, please let me know at &lt;a href="https://twitter.com/auctifer"&gt;my Twitter profile&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy hacking&lt;br&gt;
&lt;a href="https://github.com/roshnet"&gt;@roshnet&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Combined powers of Flask and Falcon</title>
      <dc:creator>Roshan Sharma</dc:creator>
      <pubDate>Mon, 30 Dec 2019 00:48:22 +0000</pubDate>
      <link>https://dev.to/roshnet/combined-powers-of-flask-and-falcon-3gol</link>
      <guid>https://dev.to/roshnet/combined-powers-of-flask-and-falcon-3gol</guid>
      <description>&lt;p&gt;Hola, people!&lt;/p&gt;

&lt;p&gt;Quite some time ago, I started learning Flask. Boy, it really got me engaged and addicted to creating web apps the "easy" way.&lt;/p&gt;

&lt;p&gt;But, it wasn't long when it got real mundane typing &lt;code&gt;from flask import whatever&lt;/code&gt; for every little project I wanted out to try. In fact, I really started to ask, "Am I learning something, or just importing flask every now and then?".&lt;/p&gt;

&lt;p&gt;Next thing you know my history is flooded with searches as in "Flask alternatives", or "Python web frameworks -flask" (&lt;code&gt;-flask&lt;/code&gt; is a Google dork, meaning &lt;code&gt;MINUS/SKIP "flask"&lt;/code&gt;) and so on, and I was overwhelmed with the number of frameworks out there.&lt;/p&gt;

&lt;p&gt;Out of all those numbers, one thing that got my tick was Falcon. I quickly navigated to it's docs, followed the tutorial, and yes - there was an app serving within minutes I read the documentation.&lt;/p&gt;

&lt;p&gt;Now, due to some random state of my mind, I decided to start a project using Falcon. I made a couple "test apps" to acquaint myself with the framework, but yeah, they didn't suffice the skillset required to create scalable apps yet.&lt;/p&gt;

&lt;p&gt;I started figuring things out, and decided to re-create a Flask project I made back in the days, using Falcon to serve as an API.&lt;/p&gt;

&lt;p&gt;It was (is) an open-source blogging site, where you can (at least) upload blogs, and share your posts' URL for people to read.&lt;/p&gt;

&lt;p&gt;I now plan (and am working on) to introduce some more advanced features like following people, getting suggestions from people regarding possible enhancements in posts (much like GitHub PR Reviews), and, maybe some more.&lt;/p&gt;

&lt;p&gt;I've hosted the app here - &lt;a href="https://blogstate.pythonanywhere.com"&gt;https://blogstate.pythonanywhere.com&lt;/a&gt;&lt;br&gt;
running on the source - &lt;a href="https://github.com/roshnet/blogstate-refactor"&gt;https://github.com/roshnet/blogstate-refactor&lt;/a&gt;&lt;br&gt;
based on the API - &lt;a href="https://github.com/roshnet/blogstate-api"&gt;https://github.com/roshnet/blogstate-api&lt;/a&gt;&lt;br&gt;
which is deployed somewhere top-secret ;&amp;gt;&lt;/p&gt;

&lt;p&gt;If (by the slightest chance) you might wanna suggest anything or help me out in code, please open a PR on the linked repositories, or &lt;a href="https://github.com/roshnet/blogstate-refactor/issues/new"&gt;submit an issue&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks for your time!&lt;/p&gt;

</description>
      <category>python</category>
      <category>falcon</category>
      <category>flask</category>
      <category>api</category>
    </item>
  </channel>
</rss>
