<?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: Dan Hackworth</title>
    <description>The latest articles on Forem by Dan Hackworth (@din0saur5).</description>
    <link>https://forem.com/din0saur5</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%2F1187396%2F0ce383cd-44ea-42f3-9a78-0d2440de9666.png</url>
      <title>Forem: Dan Hackworth</title>
      <link>https://forem.com/din0saur5</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/din0saur5"/>
    <language>en</language>
    <item>
      <title>Integrating Vite with Flask for Production</title>
      <dc:creator>Dan Hackworth</dc:creator>
      <pubDate>Mon, 15 Jan 2024 20:04:58 +0000</pubDate>
      <link>https://forem.com/din0saur5/integrating-vite-with-flask-for-production-28af</link>
      <guid>https://forem.com/din0saur5/integrating-vite-with-flask-for-production-28af</guid>
      <description>&lt;p&gt;In this post, we'll explore how to configure Vite and Flask to run seamlessly together in a production environment. This setup is ideal for developers looking to leverage the speed of Vite for frontend development with the power and simplicity of Flask for the backend.&lt;/p&gt;

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

&lt;p&gt;Before we dive into the configurations, let's assume you have the basic project structure set up. This includes a standard Flask application and a Vite-powered React frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Vite for Development
&lt;/h2&gt;

&lt;p&gt;We start by setting up our &lt;strong&gt;vite.config.js&lt;/strong&gt; file for the development environment. The configuration ensures that Vite serves our React frontend and proxies API requests to our Flask backend.&lt;/p&gt;

&lt;p&gt;Here's the &lt;strong&gt;vite.config.js&lt;/strong&gt; file for development:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vite&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;react&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@vitejs/plugin-react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// https://vitejs.dev/config/&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;base&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;react&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;assetsDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;static&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;cors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;proxy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://127.0.0.1:5555/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;changeOrigin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;secure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;rewrite&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;api/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&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;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;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The base is set to './' to ensure that the built paths are relative.&lt;/li&gt;
&lt;li&gt;assetsDir is configured as 'static', aligning with Flask's static file serving convention.&lt;/li&gt;
&lt;li&gt;The development server runs on port 3000.&lt;/li&gt;
&lt;li&gt;CORS is enabled for development.&lt;/li&gt;
&lt;li&gt;A proxy is set up for requests starting with /api, redirecting them to the Flask server running on &lt;a href="http://127.0.0.1:5555/"&gt;http://127.0.0.1:5555/&lt;/a&gt;.
##Adapting Configuration for Production
For production, we simplify the configuration by removing the development server settings. Since Flask will serve our static files in production, we don't need Vite's development server and its proxy settings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the production version of &lt;strong&gt;vite.config.js&lt;/strong&gt;, simply omit the &lt;strong&gt;server&lt;/strong&gt; object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ... rest of the configuration&lt;/span&gt;
&lt;span class="nx"&gt;build&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;assetsDir&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;static&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="c1"&gt;// No server object for production&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the upcoming sections, we'll dive deeper into how to configure Flask to serve the Vite-built assets and ensure that both Flask and Vite work harmoniously in a production setting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Backend Configuration in Flask
&lt;/h2&gt;

&lt;p&gt;Moving to the backend, let's talk about the Flask configuration. While many developers prefer to place the Flask app initialization in &lt;strong&gt;app.py&lt;/strong&gt;, I choose to place it in &lt;strong&gt;config.py&lt;/strong&gt;. This keeps all configurations centralized, making the codebase cleaner and easier to maintain.&lt;/p&gt;

&lt;p&gt;Furthermore, for production, special attention is given to how the &lt;strong&gt;static_folder&lt;/strong&gt; and &lt;strong&gt;template_folder&lt;/strong&gt; are set up, especially since we're integrating with a Vite frontend. Here's what the &lt;strong&gt;config.py&lt;/strong&gt; file looks like in production:&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;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;

&lt;span class="nf"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&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="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_bcrypt&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Bcrypt&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_migrate&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Migrate&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_restful&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Api&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_sqlalchemy&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SQLAlchemy&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sqlalchemy&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;MetaData&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_cors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CORS&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;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;static_folder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;../client/dist/static&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;template_folder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;../client/dist&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="n"&gt;secret_key&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="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SECRET_KEY&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="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SQLALCHEMY_DATABASE_URI&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&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="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SUPABASE_URI&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="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SQLALCHEMY_TRACK_MODIFICATIONS&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SESSION_COOKIE_NAME&lt;/span&gt;&lt;span class="sh"&gt;'&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;id&lt;/span&gt;&lt;span class="sh"&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SESSION_COOKIE_SECURE&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SESSION_COOKIE_HTTPONLY&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SESSION_COOKIE_SAMESITE&lt;/span&gt;&lt;span class="sh"&gt;'&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;None&lt;/span&gt;&lt;span class="sh"&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;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compact&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

&lt;span class="n"&gt;metadata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MetaData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;naming_convention&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;fk&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;fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s&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="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SQLAlchemy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;migrate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Migrate&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;db&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&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="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;bcrypt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Bcrypt&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;api&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Api&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="nc"&gt;CORS&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the production setup in &lt;strong&gt;app.py&lt;/strong&gt;, it's essential to add a catch-all route to handle redirects for single-page applications:&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="nd"&gt;@app.route&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;defaults&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;path&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="p"&gt;})&lt;/span&gt;
&lt;span class="nd"&gt;@app.route&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;path:path&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;catch_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;render_template&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;index.html&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;app&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup ensures that all routes are correctly redirected to the &lt;strong&gt;index.html&lt;/strong&gt; file, a common requirement for single-page applications in production.&lt;/p&gt;

&lt;p&gt;Building and Starting the App&lt;br&gt;
When deploying to a platform like Render or similar, ensure you use Gunicorn for the backend. Assuming your project is structured into two separate folders (&lt;strong&gt;client&lt;/strong&gt; for the frontend and &lt;strong&gt;server&lt;/strong&gt; for the backend) and your Pipenv dependencies are transferred into a &lt;strong&gt;requirements.txt&lt;/strong&gt; file, (which can be done via command pip freeze &amp;gt; requirements.txt) your build command would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--prefix&lt;/span&gt; client &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm run build &lt;span class="nt"&gt;--prefix&lt;/span&gt; client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the start command for Gunicorn would be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gunicorn &lt;span class="nt"&gt;--chdir&lt;/span&gt; server app:app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Overcoming Limitations: Serving Images from the Public Folder
&lt;/h2&gt;

&lt;p&gt;A limitation I encountered with this setup involved serving images from the &lt;strong&gt;public&lt;/strong&gt; folder. Vite handles this well in development, but Flask doesn't automatically serve these files in production. To overcome this, I utilized Supabase's storage feature, which provided a more scalable and professional solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Supabase Storage&lt;/strong&gt; and Server-Side Rendering&lt;br&gt;
Images are uploaded to &lt;a href="https://supabase.io/"&gt;Supabase&lt;/a&gt;, offering a scalable and efficient solution. The Flask backend fetches image URLs server-side, and the frontend, served by Vite, displays the images. This method enhanced scalability and performance.&lt;/p&gt;

&lt;p&gt;Implementation Overview&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Uploading Images to Supabase Storage:&lt;/strong&gt; Secure and structured storage solution.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.&lt;strong&gt;Fetching Image URLs Server-Side:&lt;/strong&gt; Flask backend dynamically retrieves image URLs.&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Rendering Images in the Frontend:&lt;/strong&gt; Vite-served frontend displays images using these URLs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This challenge led to discovering a robust solution. Using Supabase Storage for image handling not only addressed the initial issue but also added significant benefits in scalability and performance. This approach, combining Flask's server-side capabilities with Supabase's storage, resulted in a more professional and scalable application.&lt;/p&gt;

&lt;p&gt;Combining Vite and Flask for a production environment offers an efficient and modern web development experience. By addressing and overcoming specific challenges, the integration of these two powerful tools can lead to the creation of high-performance, scalable web applications.&lt;/p&gt;

</description>
      <category>vite</category>
      <category>flask</category>
      <category>production</category>
      <category>supabase</category>
    </item>
    <item>
      <title>Building a React-Flask Project with a Custom Node.js Template Generator and Tailwind CSS: A Deep Dive into CORS Setup</title>
      <dc:creator>Dan Hackworth</dc:creator>
      <pubDate>Fri, 22 Dec 2023 07:04:50 +0000</pubDate>
      <link>https://forem.com/din0saur5/building-a-react-flask-project-with-a-custom-nodejs-template-generator-and-tailwind-css-a-deep-dive-into-cors-setup-4jgp</link>
      <guid>https://forem.com/din0saur5/building-a-react-flask-project-with-a-custom-nodejs-template-generator-and-tailwind-css-a-deep-dive-into-cors-setup-4jgp</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the realm of full-stack development, the combination of React and Flask has become increasingly popular. To streamline the development process of a recent group project, I embarked on creating a custom Node.js template generator. This tool laid the groundwork for our React-Flask application, integrating the utility of Tailwind CSS and delving into the intricacies of setting up Cross-Origin Resource Sharing (CORS) in Flask.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Role of the Node.js Template Generator
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Streamlining Project Initialization
&lt;/h3&gt;

&lt;p&gt;Building a project from scratch can be time-consuming. To address this, I developed a template generator in Node.js. This generator automatically set up a basic structure for our React-Flask project, ensuring a quick and consistent start for all team members. It scaffolded the necessary directories, preconfigured essential dependencies, and integrated Tailwind CSS for styling.&lt;/p&gt;

&lt;h3&gt;
  
  
  Incorporating Tailwind CSS
&lt;/h3&gt;

&lt;p&gt;Tailwind CSS was chosen for its utility-first approach, which significantly accelerated the development of our project's UI. The template generator included Tailwind CSS configuration, enabling us to focus on building features rather than worrying about initial setup nuances.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deep Dive into CORS Setup in Flask
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Understanding CORS
&lt;/h3&gt;

&lt;p&gt;In our project, the React frontend and Flask backend were served on different origins during development, leading to CORS errors. CORS is a security feature that restricts web browsers from making requests to a different domain than the one that served the web page. To enable seamless communication between our frontend and backend, setting up CORS in Flask was crucial.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring CORS in Flask
&lt;/h3&gt;

&lt;p&gt;For handling CORS in our Flask application, we used the &lt;code&gt;flask-cors&lt;/code&gt; extension. Here's a snippet of our CORS configuration:&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;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="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_cors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CORS&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;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;cors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CORS&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;supports_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;resources&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sa"&gt;r&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;origins&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://127.0.0.1:5174&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;methods&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;GET&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;POST&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;PATCH&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;PUT&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;DELETE&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;allow_headers&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Content-Type&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;Authorization&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="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This configuration allowed us to specify which origins, HTTP methods, and headers were permissible in cross-origin requests. The supports_credentials=True setting was particularly important for handling cookies and authentication headers in our API requests.&lt;/p&gt;

&lt;p&gt;Key Takeaways from CORS Setup&lt;br&gt;
Flexibility: The flask-cors extension offered flexibility to define CORS rules as per our project's requirements.&lt;br&gt;
Security: Proper CORS setup ensured that our application remained secure while allowing necessary cross-origin requests.&lt;br&gt;
Development Efficiency: Configuring CORS correctly was vital for the development efficiency, as it enabled the frontend and backend to communicate without any hindrance.&lt;br&gt;
Conclusion&lt;br&gt;
Creating a custom Node.js template generator proved to be a significant efficiency booster for our React-Flask project. It not only provided a solid starting point but also ensured consistency across the development team. Integrating Tailwind CSS through the generator allowed for rapid UI development. Most importantly, understanding and implementing CORS in Flask was a critical learning experience, highlighting the importance of web security while developing modern web applications. This project was not just about building a functional application; it was an enriching journey through the landscape of full-stack development.&lt;br&gt;
This configuration allowed us to specify which origins, HTTP methods, and headers were permissible in cross-origin requests. The &lt;code&gt;supports_credentials=True&lt;/code&gt; setting was particularly important for handling cookies and authentication headers in our API requests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Takeaways from CORS Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Flexibility&lt;/strong&gt;: The &lt;code&gt;flask-cors&lt;/code&gt; extension offered flexibility to define CORS rules as per our project's requirements.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Security&lt;/strong&gt;: Proper CORS setup ensured that our application remained secure while allowing necessary cross-origin requests.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Development Efficiency&lt;/strong&gt;: Configuring CORS correctly was vital for the development efficiency, as it enabled the frontend and backend to communicate without any hindrance.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Creating a custom Node.js template generator proved to be a significant efficiency booster for our React-Flask project. It not only provided a solid starting point but also ensured consistency across the development team. Integrating Tailwind CSS through the generator allowed for rapid UI development. Most importantly, understanding and implementing CORS in Flask was a critical learning experience, highlighting the importance of web security while developing modern web applications. This project was not just about building a functional application; it was an enriching journey through the landscape of full-stack development.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Unlocking the Secrets of Full-Stack Magic</title>
      <dc:creator>Dan Hackworth</dc:creator>
      <pubDate>Thu, 30 Nov 2023 21:43:46 +0000</pubDate>
      <link>https://forem.com/din0saur5/unlocking-the-secrets-of-full-stack-magic-3cin</link>
      <guid>https://forem.com/din0saur5/unlocking-the-secrets-of-full-stack-magic-3cin</guid>
      <description>&lt;p&gt;&lt;strong&gt;Unlocking the Secrets of  Full-Stack Magic&lt;/strong&gt;&lt;br&gt;
Greetings fellow coding enthusiasts! Today, I want to take you on my journey learning back end development for the very first time. Truth be told I struggled quite a bit in the beginning to grasp the concepts. The blocker I had was that I couldn’t see the bigger picture and how these pieces all fit together. As I delve into the intricacies, I'll share how understanding the broader landscape of full-stack development has been a game-changer for my learning journey.&lt;br&gt;
In Python, everything is an object, from simple data types to complex structures. Understanding the fundamentals of classes and objects has been pivotal in my coding adventures. It's akin to having a set of blueprints that dictate the structure and behavior of your code entities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connecting the Dots: Full-Stack Development Unveiled&lt;/strong&gt;&lt;br&gt;
Now, let's zoom out and talk about the bigger picture. Full-stack development is the orchestration of a symphony where the backend, frontend, and database harmoniously play their parts. Imagine a restaurant where chefs (backend), servers (frontend), and the recipe book (database) work together seamlessly.&lt;br&gt;
The backend is the powerhouse, handling logic, processing requests, and serving data. Python, with its versatility, becomes a maestro in this realm. Queries to the database are like placing an order – precise and tailored to get exactly what's needed. The database responds with the requested data, completing the back-end's mission.&lt;br&gt;
On the other side of the curtain, the frontend takes this data and presents it to the user. It's the part of the show everyone sees. The user interacts with the interface, blissfully unaware of the complex “dance" happening behind the scenes. Here, Python may not be the star, but it's the silent puppeteer pulling the strings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Bump in the Learning Road&lt;/strong&gt;&lt;br&gt;
Now, let's address the elephant in the room – the challenges of learning. My journey wasn’t all smooth sailing. My initial teachers were unfortunately let go. It was a shock and a setback, but the silver lining is that– connections endure.&lt;br&gt;
Despite the challenges, staying in contact with my former teachers has been a game-changer, especially with the continuing guidance in my side projects, particularly a full-stack PERN-style template, has been invaluable. In modeling it after create-react-app using Node and Commander, I've begun to see the intricate connections between frontend and backend. It's not just about writing code; it's about architecting a system that communicates flawlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Seeing the Bigger Picture&lt;/strong&gt;&lt;br&gt;
Working on these projects has given me a glimpse of the big picture. It's not just about mastering a language or framework; it's about understanding how each piece fits into the puzzle. Object-Oriented Programming principles, applied both in Python and across the full-stack spectrum, have been the glue holding everything together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Closing Thoughts&lt;/strong&gt;&lt;br&gt;
So, as I continue my journey towards becoming a great full-stack developer, I invite you to embark on your own exploration. Understand the nuances of OOP, MCV, and other modern solutions in full-stack development, and always remember – even when situations change, the learning never stops. It's not just about writing code; it's about creating magic.&lt;br&gt;
Happy coding!&lt;/p&gt;

</description>
      <category>python</category>
      <category>oop</category>
      <category>backend</category>
    </item>
    <item>
      <title>Conversations with Computers: Coding as an Art Form</title>
      <dc:creator>Dan Hackworth</dc:creator>
      <pubDate>Fri, 10 Nov 2023 15:57:05 +0000</pubDate>
      <link>https://forem.com/din0saur5/conversations-with-computers-coding-as-an-art-form-49a3</link>
      <guid>https://forem.com/din0saur5/conversations-with-computers-coding-as-an-art-form-49a3</guid>
      <description>&lt;p&gt;“Conversations with computers: Coding as an Art Form”&lt;br&gt;
A continuation of my last post, Coding as Communication. To picture the computer as a living entity; the computer is ready to be put into motion. The list of possible commands is vast and ever changing. When the computer does fail an operation the fault lies on its technological limitations or more likely, the communicator of code. There are many different ways to convey a message to a computer but clarity and precision in coding is paramount. As my last post asserted,  Code is the way we speak to our computers. Recently, I have been learning to code in React, a framework of JS,  geared toward front-end development. In a sense, I have learned a new “dialect”.&lt;/p&gt;

&lt;p&gt;React varies from vanilla JS because it makes adding web components modular and declarative. Simply put, I can build a reusable piece of the puzzle and place it directly where I want, rather than explaining every step, for every action. To dive deeper into my experience with react, I have been able to produce beautiful web pages like my new improved website (daniel-hackworth.com) that would have previously been exceedingly difficult in traditional JS. My most notable takeaway from React is how to use it’s modularity and libraries. Imagine if you are training someone to do a job. You could write your own how-to manuel every time and then you get full control over it. Or you could use an already written how-to manuel, oftentimes, by someone(s) more advanced; though these manuals may become out of date, or surpass your code. The benefits and problems essentially boil down to saving time now vs saving time later. &lt;/p&gt;

&lt;p&gt;“Making Living Art”&lt;br&gt;
 Software Engineering is an art form like how bees create a hive and ants a network of tunnels. Function and beauty working in tandem; it reminds me of training bonsai trees. You have to prune and style heavily, taking care not to destroy it. Like code, deciding what should stay and what should go, are the lines readable to others, are they vulnerable to bugs. Each branch must be gently but precisely guided to take the proper shape. The program is the tree and it grows as you add to it but must be constantly maintained and formed. When it begins to take shape, it takes time and skill to grow into a finished form. Yet, even in its finished form it must still be maintained. Coding is more forgiving as there is an undo button and ample testing. Even still, there is a necessary emphasis on patience, adaptability and finding the right guidance. There is more to learn than any one human can know. &lt;/p&gt;

&lt;p&gt;So far I have been really enjoying this journey, and passionately studying to keep up and learn the newest things. Thus far, I have put most of my effort into learning design and front end development. Starting next week is our delve into back end development. There are many more programming languages that I have yet to study but all have their strengths and weaknesses. Which I hope to discuss in my next post when I have learned more about python.&lt;/p&gt;

</description>
      <category>react</category>
      <category>code</category>
      <category>frontend</category>
      <category>bonsai</category>
    </item>
    <item>
      <title>Initial Commit</title>
      <dc:creator>Dan Hackworth</dc:creator>
      <pubDate>Thu, 19 Oct 2023 15:10:28 +0000</pubDate>
      <link>https://forem.com/din0saur5/initial-commit-49nh</link>
      <guid>https://forem.com/din0saur5/initial-commit-49nh</guid>
      <description>&lt;h1&gt;
  
  
  My Journey into Software Engineering: Decoding the Language of Computers
&lt;/h1&gt;

&lt;p&gt;Hello, My name is Daniel Hackworth, I am a 26 year old software engineer. I got into coding several months ago and it was a wild journey! I was not a computer guy, I took a couple classes in high school but that was the extent of my knowledge. I used a chromebook because I got it on sale and didn’t do much more than what google drive offered, and surfing the web. One day, I wasn’t paying attention and someone stole my chromebook. I was angry about it but everything I really cared about was backed up. Luckily my best friend had an old, but still very powerful, laptop he was willing to sell me for a good price. Then I got very sick and fell behind on my bookkeeping for work. Through that harrowing experience I found it necessary to find a faster way. I wasn’t wealthy enough to hire someone else to do it. So I set off on learning to code my first program. With my better computer, the help of chat-gpt, and plenty of fumbling around; I was able to create my first program. I had so much fun with it, that I started making programs for other easily automatable tasks and time savers. I began creating more complex programs when I wasn’t working. Then, got it in my head that maybe I could get paid to write programs. When I realized that I would be losing my housing within 6 months and I wasn’t making enough money with my current job to get a new place. I got that push I needed to take a leap of faith to quit my job and join a coding bootcamp.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mathematics in a Foreign Land
&lt;/h2&gt;

&lt;p&gt;I feel lucky that coding was a passion before I attempted to make it a career. I go into every problem thoroughly enjoying the puzzles and problem solving. Having the basics on how to “speak computer” has helped me immensely going into my bootcamp experience. My philosophy on coding is deeply rooted in communication. I often describe learning to code as going into a foreign country to take a class on algebra. Assuming you have taken an algebra class before or at least understand the basics, experiencing a teacher teach in a different language can be daunting, confusing, and cause much miscommunication. But, the logical problem-solving techniques in algebra don’t change much regardless of what language it is being taught in. Taking your time to understand more of the language you are learning by using the algebra skills you already possess to make cross-subject references and unlock more vocabulary and syntax based on what you do know and any outside help you can reference; will leave you with an understanding of the new language and a much more solid understanding of algebra.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Language of Code
&lt;/h2&gt;

&lt;p&gt;To continue on this philosophy, like traditional language, coding language syntax and vocabulary is vast and influenced by many very different people. So just like communication there are many different ways to communicate the same ideas, some better than others in regards to different situations. These solutions are also limited by the “speaker’s” and "listener's" vocabulary. In the case of coding, the listener(the computer) has all the vocabulary; so it is only limited by the coder. As a speaker, the best way to increase your lexicon is by reading books that use words in contextual and complex ideas, in tandem with a dictionary for reference. If you read a book far above your reading level it simply wouldn’t make sense, and if you read a dictionary, you would lose necessary contextual value. I have found that coding is exactly the same; and the best way to learn is looking at or copying code that is just out of reach, with reference material handy.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>coding</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
