<?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: Benjamin Bliss</title>
    <description>The latest articles on DEV Community by Benjamin Bliss (@benpaixd).</description>
    <link>https://dev.to/benpaixd</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%2F1103840%2F1200a964-51b6-4caf-b5fc-75ba2837e6c6.png</url>
      <title>DEV Community: Benjamin Bliss</title>
      <link>https://dev.to/benpaixd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/benpaixd"/>
    <language>en</language>
    <item>
      <title>Building a webchat site from scratch, part 2</title>
      <dc:creator>Benjamin Bliss</dc:creator>
      <pubDate>Thu, 22 Jun 2023 04:58:19 +0000</pubDate>
      <link>https://dev.to/benpaixd/building-a-webchat-site-from-scratch-part-2-103n</link>
      <guid>https://dev.to/benpaixd/building-a-webchat-site-from-scratch-part-2-103n</guid>
      <description>&lt;p&gt;Today I did a good amount of restructuring and replanning on how I want to handle this project.  As I was looking into how to do front end development with JavaScript I began to get really lost as I was trying to connect it all back to the backend Python side of it.  Not good considering on that side of things I am still learning and as such my knowledge is shaky.  Thankfully I came across another tutorial from the Youtuber TechWithTim on creating a website (which can be found here: &lt;a href="https://www.youtube.com/watch?v=dam0GPOAvVI"&gt;&lt;br&gt;
Python Website Full Tutorial&lt;/a&gt;), where he uses a Flask backend and but uses Jinja with Bootstrap in the html to simplify that side of the project so the focus could be on the back end.  &lt;/p&gt;

&lt;p&gt;I restructured the project to better organized the files as the project grew.  I created a 'website' package to store just about everything except for app.py, see below.&lt;/p&gt;

&lt;p&gt;In it is of course the &lt;strong&gt;init&lt;/strong&gt;.py file, signaling that the folder is a package.  That file contains the following code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lUjNYEp3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0x6dudf21c9unhhkqwvo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lUjNYEp3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0x6dudf21c9unhhkqwvo.png" alt="Image description" width="254" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;app.py is where the app launches from, the static folder is future proofing for JavaScript/TypeScript files in the future and in a similar vein, the models.py will be for modelling the sql database down the line. The templates folder contains all the .html files. Thanks to Jinja making the html as been a lot easier.  It allows you to make a base template file to act as a skeleton for the rest of your production html files to build off of reducing the amount of code you have to write.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;init&lt;/strong&gt;.py file is what allows the website folder to be seen as a Python package by app.py. It contains the code below&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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;init_app&lt;/span&gt;&lt;span class="p"&gt;():&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="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'SECRET_KEY'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"nC1iuUeNlNe"&lt;/span&gt;

    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;.views&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;.auth&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;auth&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;register_blueprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url_prefix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&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="n"&gt;register_blueprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;url_prefix&lt;/span&gt;&lt;span class="o"&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;return&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After creating the Flask app it grabs the pages designed/specified in the views.py and auth.py files so they can be reached by the app.&lt;/p&gt;

&lt;p&gt;While there is still no actual functionality I was able to build some pages for the sign up and log in pages&lt;/p&gt;

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

&lt;p&gt;All code can be found at the link below :)&lt;br&gt;
&lt;a href="https://github.com/BenpaiXD/webchat/tree/main"&gt;webchat&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building a webchat site from scratch, part 1</title>
      <dc:creator>Benjamin Bliss</dc:creator>
      <pubDate>Sun, 18 Jun 2023 21:47:35 +0000</pubDate>
      <link>https://dev.to/benpaixd/building-a-webchat-site-from-scratch-part-1-2m3p</link>
      <guid>https://dev.to/benpaixd/building-a-webchat-site-from-scratch-part-1-2m3p</guid>
      <description>&lt;p&gt;Today I've learned about Python's virtual environment, aka venv. The venv folder seems to be an unique environment used for each independent project. Python isn't very good at dependency management and for every new package you install, they will be stored in the &lt;code&gt;site-packages/&lt;/code&gt; folder at Python base installation directory. &lt;/p&gt;

&lt;p&gt;The value in having a virtual environment comes in a number of ways. first it helps avoid system pollution. Many operating systems including the one I'm using use Python for internal tasks, so installing dependencies directly may cause unintended side effects. Virtual environments avoid dependency conflicts, such that various projects depend on different versions of a package, they can each use the version they're built for.&lt;/p&gt;

&lt;p&gt;There seems to be more but this is the gist that I was able to gather, and as such I plan on using virtual environments in all my projects moving forward.&lt;/p&gt;

&lt;p&gt;To create my virtual environment I ran the following command&lt;br&gt;
&lt;code&gt;python3 -m venv venv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and to activate it I ran this in my project directory:&lt;br&gt;
&lt;code&gt;source ./venv/bin/activate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Just like that I have built a running website, not that it does much. It takes be to a page that just says welcome, as specified in the homePage function.  Its just cool to see a site up and running that quickly&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="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="c1"&gt;# create instance of flask app
&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="c1"&gt;# decorator sets this as root in website
&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;homePage&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="c1"&gt;# html that is being run on the page
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"welcome"&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="s"&gt;"__main__"&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;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;All code can be found in the repository below :)&lt;br&gt;
&lt;a href="https://github.com/BenpaiXD/webchat"&gt;https://github.com/BenpaiXD/webchat&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building a webchat site from scratch, part 0</title>
      <dc:creator>Benjamin Bliss</dc:creator>
      <pubDate>Sun, 18 Jun 2023 18:39:10 +0000</pubDate>
      <link>https://dev.to/benpaixd/building-a-webchat-site-from-scratch-part-0-1ojo</link>
      <guid>https://dev.to/benpaixd/building-a-webchat-site-from-scratch-part-0-1ojo</guid>
      <description>&lt;p&gt;Computer Science and software development is one of those fields where it doesn't seem to matter much about what school you went to or how you did in your classes. What I have come to learn is demonstrating your skills through personal projects as it shows your personal drive and passion towards your work.&lt;/p&gt;

&lt;p&gt;As I am short on some projects myself and am looking towards applying to jobs I thought this would be a great opportunity to get started on some projects of my own hence the building of this webchat.  I'm starting off simple with just a chat webapp as I think it will teach me about front and back end development, data storage and more.  &lt;/p&gt;

&lt;p&gt;I've decided to make it in two languages.  I've chosen to make the front end in TypeScript as I'm not very familiar with JavaScript and I've heard a lot of good things about TS, with it being a straight improvement over JS.  And Python, a language I am very familiar with, but using Flask, a web application framework to handle the backend, which I am unfamiliar with.  I considered using Django, another industry standard framework, but from the research I've done, Flask seems to be lighter weight and easier to get up and running.&lt;/p&gt;

&lt;p&gt;I will be hosting this website myself, as I was able to grab an retired micro desktop from my work. I've installed Ubuntu server on to it with NodeJS, Python and any other dependencies I may need and I'll be connecting to it through SSH from my PC and laptop to work on it.&lt;/p&gt;

&lt;p&gt;This blog will be me journaling any new thing I learn through the process of building the website, noting any changes I make and milestones I reach. I will be basing the foundation of my project off this article I found: &lt;a href="https://tms-dev-blog.com/python-backend-with-javascript-frontend-how-to/"&gt;Python backend with JavaScript frontend: how to&lt;/a&gt;. It goes through setting up a website just similarly to how I want to, just I will be using TypeScript instead.&lt;/p&gt;

&lt;p&gt;With that said lets get started on the website in part 1.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>python</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
