<?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: Junior Gantin</title>
    <description>The latest articles on Forem by Junior Gantin (@nioperas06).</description>
    <link>https://forem.com/nioperas06</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%2F21837%2F94b69f23-35e7-4f88-931c-1b29c9a855aa.jpeg</url>
      <title>Forem: Junior Gantin</title>
      <link>https://forem.com/nioperas06</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/nioperas06"/>
    <language>en</language>
    <item>
      <title>Sending automated emails with Masonite Framework</title>
      <dc:creator>Junior Gantin</dc:creator>
      <pubDate>Fri, 02 Nov 2018 12:11:45 +0000</pubDate>
      <link>https://forem.com/masonite/sending-automated-emails-with-masonite-framework-13cc</link>
      <guid>https://forem.com/masonite/sending-automated-emails-with-masonite-framework-13cc</guid>
      <description>&lt;p&gt;Imagine a scenario where you want to send a weekly email to your customers (maybe a newsletter 💌). So you need to send that email at a specific day and time. &lt;/p&gt;

&lt;p&gt;This post will walk through creating and sending automated emails with &lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;Masonite Framework&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  What you’ll need
&lt;/h1&gt;

&lt;p&gt;To code along with this post, you’ll need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python (I’m using Python 3.6.5);&lt;/li&gt;
&lt;li&gt;Pipenv: Python Development Workflow for Humans;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;Masonite&lt;/a&gt;: The Modern And Developer Centric Python Web Framework&lt;/li&gt;
&lt;li&gt;Mailtrap.io: Email testing for dev teams;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setting up your application
&lt;/h1&gt;

&lt;p&gt;First, create a new directory and a Python virtualenv:&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="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;masonite-weekly-email
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;masonite-weekly-email
&lt;span class="nv"&gt;$ &lt;/span&gt;pipenv &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--three&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;pipenv shell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, you'll need to install &lt;code&gt;masonite-cli&lt;/code&gt; package and crafting a new &lt;br&gt;
&lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;Masonite&lt;/a&gt; application.&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="nv"&gt;$ &lt;/span&gt;pipenv &lt;span class="nb"&gt;install &lt;/span&gt;masonite-cli
&lt;span class="nv"&gt;$ &lt;/span&gt;craft new masonite_weekly_email &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;craft &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a new Masonite application inside your current directory (the use of &lt;code&gt;.&lt;/code&gt; at the end of &lt;code&gt;craft new&lt;/code&gt; command).&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating and sending an Email
&lt;/h1&gt;

&lt;p&gt;Masonite comes with email support out of the box 🎉. So you can easily send an email like this:&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="n"&gt;Mail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hello@email.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;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;mail/welcome&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Task Scheduling
&lt;/h1&gt;

&lt;p&gt;Now that we are done with sending email, let's schedule it. &lt;br&gt;
Masonite provides a package called &lt;a href="https://docs.masoniteproject.com/useful-features/task-scheduling" rel="noopener noreferrer"&gt;&lt;code&gt;masonite-scheduler&lt;/code&gt;&lt;/a&gt;. It enables your app to schedule cron tasks. First, you need to run a command to install the package:&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="nv"&gt;$ &lt;/span&gt;pipenv &lt;span class="nb"&gt;install &lt;/span&gt;masonite-scheduler
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second command is a &lt;code&gt;craft task&lt;/code&gt; command which will create a new task under the &lt;code&gt;app/tasks&lt;/code&gt; directory.&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="nv"&gt;$ &lt;/span&gt;craft task WeeklyEmail
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before running our task weekly, let's run it every 1 minute.&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;scheduler.Task&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;WeeklyEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="n"&gt;run_every&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;1 minute&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Mail&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mail&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Mail&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Build your next SaaS with Masonite 🚀&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="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hello@email.com&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;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;mail/weekly&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="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Above, you send a email with a template located under &lt;code&gt;mail&lt;/code&gt; folder. Create a file called &lt;code&gt;weekly.html&lt;/code&gt; and put a random text inside.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Hello world!&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://github.com/MasoniteFramework/masonite"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Masonite&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt; is magic. ✨ &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    There are many benefits Masonite brings to your next SaaS project.
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://media.giphy.com/media/3o6Ztqh4JSlVqi2Z20/giphy.gif"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"just do it"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's test this before setting up a cron job. Put your &lt;a href="https://mailtrap.io/" rel="noopener noreferrer"&gt;Mailtrap&lt;/a&gt; credentials into your &lt;code&gt;.env&lt;/code&gt; file and run this command.&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="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;craft&lt;/span&gt; &lt;span class="n"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's Masonite fetch and run your task!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj6vsqnershm53an4ortj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj6vsqnershm53an4ortj.gif" alt="Alt Text" width="488" height="606"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's put the right parameters and tell the task when it should run (remember a weekly email).&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;class&lt;/span&gt; &lt;span class="nc"&gt;WeeklyEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;run_every&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;7 days&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;run_at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;17:00&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

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

&lt;/div&gt;



&lt;h1&gt;
  
  
  Cron Jobs
&lt;/h1&gt;

&lt;p&gt;You need to set up the Cron Jobs to run automatically our tasks. Each crontab line must start with a time at which the command should be run and then the command:&lt;br&gt;
So, to run &lt;code&gt;command&lt;/code&gt; at 17:00 every monday, you'd do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;00 17 * * 1 command
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need to append &lt;code&gt;&amp;amp;&amp;amp; craft schedule:run&lt;/code&gt; to run your run the scheduled task.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.masoniteproject.com/useful-features/task-scheduling" rel="noopener noreferrer"&gt;Masonite Task Scheduling&lt;/a&gt; documentation page can provide further information. Just read it ✊!&lt;/p&gt;

&lt;p&gt;If you want to contribute or interested in the development of &lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;Masonite&lt;/a&gt; then be sure to join the &lt;a href="http://slack.masoniteproject.com/" rel="noopener noreferrer"&gt;Slack&lt;/a&gt; channel or star the repo on &lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>framework</category>
      <category>masonite</category>
    </item>
    <item>
      <title>Let's make Masonite Framework and Laravel Mix work together </title>
      <dc:creator>Junior Gantin</dc:creator>
      <pubDate>Wed, 22 Aug 2018 22:22:48 +0000</pubDate>
      <link>https://forem.com/nioperas06/lets-make-masonite-framework-and-laravel-mix-work-together--3lbj</link>
      <guid>https://forem.com/nioperas06/lets-make-masonite-framework-and-laravel-mix-work-together--3lbj</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/MasoniteFramework/masonite"&gt;Masonite&lt;/a&gt;&lt;/strong&gt; is a beautifully crafted Web Framework for Python. We usually use files like CSS, JavaScript and image files known as &lt;strong&gt;Web assets&lt;/strong&gt; to make our web app looks great.&lt;/p&gt;

&lt;p&gt;In this article, I'll show you how you can use &lt;strong&gt;&lt;a href="https://github.com/JeffreyWay/laravel-mix"&gt;Laravel Mix&lt;/a&gt; for processing and compiling assets&lt;/strong&gt; into your &lt;strong&gt;&lt;a href="https://github.com/MasoniteFramework/masonite"&gt;Masonite&lt;/a&gt;&lt;/strong&gt; web app.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Laravel Mix?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/JeffreyWay/laravel-mix"&gt;Laravel Mix&lt;/a&gt;&lt;/strong&gt; makes &lt;strong&gt;asset compiling&lt;/strong&gt; incredibly easy.&lt;br&gt;
Using &lt;strong&gt;&lt;a href="https://github.com/JeffreyWay/laravel-mix"&gt;Laravel Mix&lt;/a&gt;&lt;/strong&gt; with &lt;strong&gt;&lt;a href="https://github.com/MasoniteFramework/masonite"&gt;Masonite&lt;/a&gt;&lt;/strong&gt; is really a simple task. There we go!&lt;/p&gt;
&lt;h1&gt;
  
  
  Create a new Masonite project
&lt;/h1&gt;

&lt;p&gt;Before we get started, create a new Masonite project. Just install Masonite's CLI called &lt;strong&gt;craft&lt;/strong&gt;.&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="nv"&gt;$ &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;masonite-cli
&lt;span class="nv"&gt;$ &lt;/span&gt;craft new masonite_laravel_mix
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;masonite_laravel_mix
&lt;span class="nv"&gt;$ &lt;/span&gt;craft &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Install and setup Laravel Mix
&lt;/h1&gt;

&lt;p&gt;Laravel Mix can be used for any type of application, not just for Laravel apps. To get started, just install laravel-mix as our project dependency.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install laravel-mix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Put webpack config file into our project root.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cp node_modules/laravel-mix/setup/webpack.mix.js .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then, add this sample script into webpack.mix.js like &lt;a href="https://github.com/laravel/laravel/blob/master/webpack.mix.js"&gt;Laravel&lt;/a&gt; does.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is definition of our asset pipeline. It's time to add some &lt;strong&gt;npm scripts&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I just copied this npm scripts from &lt;a href="https://github.com/laravel/laravel/blob/master/package.json"&gt;Laravel repository&lt;/a&gt; - again 😅.&lt;br&gt;
This scripts helps in asset compilation for development or production.&lt;br&gt;
As you can see it, you need to install cross-env to make it works well.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install cross-env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now that we’ve done all the hard work, let’s go ahead and a simple html file.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
&amp;lt;link rel="stylesheet" href="/public/css/app.css"&amp;gt;
...
&amp;lt;script src="/public/js/app.js"&amp;gt;&amp;lt;/script&amp;gt;
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Simple thing to make all this stuff work is to create a template alias. All configurations that are specific to static files can be found in &lt;code&gt;config/storage.py&lt;/code&gt;. &lt;br&gt;
In this file we'll add a constant to STATICFILES which is simply a dictionary:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;STATICFILES = {
    # folder  # template alias
    'public': 'public/'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We did it 🎉 🎉 🎉! You should see a screen similar to this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j27wtpIK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/i2q894fghtwrwzfu5krz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j27wtpIK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/i2q894fghtwrwzfu5krz.png" alt="Masonite &amp;amp; Laravel Mix"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can watch this &lt;a href="https://github.com/nioperas06/masonite-laravel-mix"&gt;repository&lt;/a&gt; where I add Bootstrap as dependencies and use it as sample!&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3JOwpme--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/nioperas06"&gt;
        nioperas06
      &lt;/a&gt; / &lt;a href="https://github.com/nioperas06/masonite-laravel-mix"&gt;
        masonite-laravel-mix
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      🎨 Masonite and Laravel Mix for processing and compiling assets 
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Masonite - Laravel Mix&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;Let's make Laravel Mix and Masonite Framework work together.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This application is a demo on how you can use Laravel Mix for processing and compiling assets.&lt;/p&gt;
&lt;p&gt;View tutorial: &lt;a href="https://dev.to/nioperas06/lets-make-masonite-framework-and-laravel-mix-work-together--3lbj" rel="nofollow"&gt;Link&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Built With:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/MasoniteFramework/masonite"&gt;Masonite&lt;/a&gt; - The Modern And Developer Centric Python Web Framework.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/JeffreyWay/laravel-mix"&gt;Laravel Mix&lt;/a&gt; - An elegant wrapper around Webpack for the 80% use case.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/nioperas06/masonite-laravel-mix"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Hopefully this article has helped you understand how Masonite and Laravel Mix can be used together for processing and compiling assets. If you want to contribute or interested in the development of Masonite then be sure to join the &lt;a href="http://slack.masoniteproject.com/"&gt;Slack&lt;/a&gt; or star &lt;a href="https://github.com/MasoniteFramework/masonite"&gt;Masonite's repository&lt;/a&gt; on GitHub.&lt;/p&gt;

</description>
      <category>python</category>
      <category>framework</category>
      <category>masonite</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Build Email Verification from Scratch With Masonite Framework and JSON Web Tokens</title>
      <dc:creator>Junior Gantin</dc:creator>
      <pubDate>Thu, 09 Aug 2018 00:31:54 +0000</pubDate>
      <link>https://forem.com/nioperas06/build-email-verification-from-scratch-with-masonite-framework-and-json-web-tokens-mf7</link>
      <guid>https://forem.com/nioperas06/build-email-verification-from-scratch-with-masonite-framework-and-json-web-tokens-mf7</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;Masonite Framework&lt;/a&gt; is a modern and developer centric Python web framework. The architecture of Masonite is much more similar to the Laravel framework.&lt;/p&gt;

&lt;p&gt;In this tutorial, I’ll show you how to build email verification from scratch for your Masonite application.&lt;/p&gt;

&lt;p&gt;Masonite comes with a CLI tool called Craft. Craft provides an easy way to scaffold what you need for authentication using a simple command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ craft auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command generates everything you need for authentication: 4 new controllers, 5 new templates and 6 new routes. So you want to handle a user email verification and validate the email. There we go!&lt;/p&gt;

&lt;h2&gt;
  
  
  Create new Masonite project and scaffold authentication
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pipenv install masonite-cli
$ craft new masonite-app-with-user-verification 
$ cd masonite-app-with-user-verification 
$ craft install 
$ craft auth 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setup database
&lt;/h2&gt;

&lt;p&gt;In order to register users, we will need a database. Let’s use a MySQL Database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pipenv install PyMySQL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create new database and put your database credentials into .env file:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_DRIVER=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=masonite
DB_USERNAME=root
DB_PASSWORD=root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add ‘active’ attribute to User Model
&lt;/h2&gt;

&lt;p&gt;Let’s create a new migration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ craft migration add_active_to_users_table --table=users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, add new active attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from orator.migrations import Migration
class AddActiveToUsersTable(Migration):
    def up(self):
         with self.schema.table('users') as table:
             table.boolean('active').default(False)

    def down(self):
         with self.schema.table('users') as table:
             table.drop_column('active')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply your migrations 😄&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ craft migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why use JWT for email verification?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://jwt.io/" rel="noopener noreferrer"&gt;JSON Web Tokens&lt;/a&gt; are a good way of securely transmitting information between parties.&lt;/p&gt;

&lt;p&gt;For email verification, we need to send a random hash to registered user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate new jwt token on registration
&lt;/h2&gt;

&lt;p&gt;We need to use JSON Web Token implementation in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pipenv install PyJWT
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data = {'email': user.email}
encoded = jwt.encode(data, os.environ.get('KEY'), algorithm='HS256')
token = str(encoded, 'utf-8')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we need to send a mail. Masonite provides a package call &lt;a href="https://docs.masoniteproject.com/official-packages/masonite-notifications" rel="noopener noreferrer"&gt;notification&lt;/a&gt; that can help us perform this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pipenv install masonite-notifications
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s create a notification for email verification.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ craft notification EmailVerificationNotification
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our notification should send an e-mail with a link containing the verification token.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from notifications import Notifiable

class EmailVerificationNotification(Notifiable):
def mail(self):
    return self.subject('New account signup!') \
        .driver('smtp') \
        .heading('Masonite App With User Verification') \
        .line('In order to use your account, you have to validate your email address.') \
        .line('Please click on the link below.') \
        .action('Validate my account', href=self._link)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not bad.&lt;/p&gt;

&lt;p&gt;Then, let’s send that email to our users:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if token:
    Notify.mail(EmailVerificationNotification, to=user.email, link='http://localhost:8000/activate/{0}'.format(token))
    Session.flash(‘success’, ‘Almost done! Please check your email to complete the registration process.’)
    return Request.redirect(‘/login’)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your smtp credentials are correct, you’ll have this in your mail:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48264h41hhdjz4bs2jer.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48264h41hhdjz4bs2jer.png" alt="Email verification" width="556" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a route for email verification
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get('/activate/@token', 'RegisterController@validate')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Define fillable attribute ‘activate’ on User Model
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User(Model):
    __fillable__ = ['name', 'email', 'password', 'active']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Validate users
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def validate(self, Request):
    if Request.param('token'):
        data = jwt.decode(Request.param('token'), os.environ.get('KEY'), algorithms=[‘HS256’])
        user = User.where('email', data['email']).first()
        if user:
            user.active = True
            user.save()
            Session.flash('success', 'You\'re in! Let\'s login!')
    return Request.redirect('/login')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Last thing! Login users:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def store(self, Request, Session):
    user = User.where('email', Request.input('email')).first()
    if user.active:
        if Auth(Request).login(Request.input('email'), Request.input('password')):
            return Request.redirect('/home')
        return Request.redirect('/login')
    else:
        Session.flash('warning', 'Please check your email to complete the registration process.')
        return Request.back()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Your user is now verified 🔥
&lt;/h2&gt;

&lt;p&gt;I’ll release this stuff inside a Masonite package. If you want to contribute to the development of the package or interested in the development of Masonite then be sure to join the &lt;a href="http://slack.masoniteproject.com/" rel="noopener noreferrer"&gt;Slack channel&lt;/a&gt; or star the repo on &lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to add you comments for further discussion. The entire code for this tutorial is available on &lt;a href="https://github.com/nioperas06/masonite-app-with-user-verification" rel="noopener noreferrer"&gt;Github&lt;/a&gt;. Thanks!&lt;/p&gt;

</description>
      <category>python</category>
      <category>framework</category>
      <category>masonite</category>
    </item>
    <item>
      <title>Saying "Hello world" using Masonite Framework</title>
      <dc:creator>Junior Gantin</dc:creator>
      <pubDate>Wed, 20 Jun 2018 23:15:56 +0000</pubDate>
      <link>https://forem.com/nioperas06/saying-hello-world-using-masonite-framework-261l</link>
      <guid>https://forem.com/nioperas06/saying-hello-world-using-masonite-framework-261l</guid>
      <description>&lt;p&gt;In this post, we will build a simple Hello World application using Masonite Framework.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is &lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;Masonite Framework&lt;/a&gt;?
&lt;/h1&gt;

&lt;p&gt;According to the official &lt;a href="https://docs.masoniteproject.com/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;, Masonite is describe as a Python web framework that strives for an actual batteries included developer tool with a lot of out of the box functionality with an extremely extendable architecture. Masonite is perfect for beginner developers getting into their first web applications as well as experienced developers.&lt;/p&gt;

&lt;p&gt;Masonite uses the power of Python to offer developers a great set of features such as a simple and expressive routing engine, a powerful command line helpers, a simple migration system, a great Active Record style ORM, a great filesystem architecture for navigating and expanding your project and many more.&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's begin
&lt;/h1&gt;

&lt;p&gt;In order to use &lt;a href="https://github.com/MasoniteFramework/masonite" rel="noopener noreferrer"&gt;Masonite Framework&lt;/a&gt;, you’ll need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.4+&lt;/li&gt;
&lt;li&gt;Pip3 or Pipenv&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can now install Masonite using pip:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ pip install masonite-cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to create the Masonite project using &lt;code&gt;craft&lt;/code&gt; command line tool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ craft new hello_world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will get the latest Masonite project template inside a folder with the name hello_world. Now run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd hello_world
$ craft install
$ craft serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open your browser and visit the following address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8000/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Voila!&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F905962zllph6suneyehr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F905962zllph6suneyehr.png" alt="Masonite Framework"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Masonite is a truly MVC framework. All routes that define which action of which controller will serve are located in &lt;code&gt;routes/web.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, add the following line in &lt;code&gt;ROUTES&lt;/code&gt; list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get().route('/home', 'HomeController@home')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In Masonite, you can define a Controller method to a route. Let's create &lt;code&gt;HomeController&lt;/code&gt;. Run this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ craft controller Home
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All controllers are located in the &lt;code&gt;app/http/controllers&lt;/code&gt; directory. The &lt;code&gt;HomeController&lt;/code&gt; generated contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;''' A Module Description '''

class HomeController:
    ''' Class Docstring Description '''

    def show(self):
        pass

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

&lt;/div&gt;



&lt;p&gt;Just rename show method and return a view:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class HomeController:

    def home(self):
        return view('home')

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

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;view&lt;/code&gt; is called a helper function that do not require any imports and are simply just available 🔥. Let's create our home template with &lt;code&gt;craft&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ craft view home
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create &lt;code&gt;resources/templates/home.html&lt;/code&gt;. Change its content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Masonite is awesome!&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open your browser at &lt;code&gt;http://localhost:8000/home&lt;/code&gt; and there it is:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4lrpc8wzrop48nsuyw5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4lrpc8wzrop48nsuyw5w.png" alt="Hello world"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>framework</category>
      <category>masonite</category>
    </item>
    <item>
      <title>Deploy Angular Apps To Surge</title>
      <dc:creator>Junior Gantin</dc:creator>
      <pubDate>Sun, 14 Jan 2018 21:36:34 +0000</pubDate>
      <link>https://forem.com/nioperas06/deploy-angular-apps-to-surge-c1f</link>
      <guid>https://forem.com/nioperas06/deploy-angular-apps-to-surge-c1f</guid>
      <description>&lt;p&gt;I usually use Heroku for hosting my Angular Apps. It works fine but I want to try anything else: something new, something smart. I heard about two deploying tools dedicated to front-end developers: Netlify and Surge. In this article, I will show you how to deploy Angular apps to Surge.&lt;/p&gt;

&lt;h2&gt;
  
  
  What’s Surge?
&lt;/h2&gt;

&lt;p&gt;Surge is a simple tool for publishing HTML5 apps without leaving the command line. Surge is powerful. I took 10 or 20 minutes sometimes for publishing Angular Apps on Heroku because you need to create a Procfile, add express and angular-cli on app’s dependencies and so on. But with Surge, you need to build your app and it’s alive!&lt;/p&gt;

&lt;h2&gt;
  
  
  How to do it?
&lt;/h2&gt;

&lt;p&gt;First install Surge using npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npm install -g surge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new Angular app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ng new angular-surge
$ cd angular-surge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What you need to do now is to build your application for production environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ng build --prod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now angular-cli put the build artifacts into dist folder. You need to deploy this folder with surge. Let’s move into dist folder with command line and start deploying.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd dist
$ surge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Voila! Account creation will happen on your first run. Surge will show you where your application is alive on. Enjoy!&lt;/p&gt;

&lt;p&gt;You can do more with Surge. Custom domain, 404 page, SSL and so more. Here is where you can start with these functionalities of Surge.&lt;/p&gt;

&lt;p&gt;Never forget that you can deploy your Angular apps in one minute or less with Surge!!!&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;br&gt;
Originally published at &lt;a href="https://medium.com/@nioperas06/deploy-angular-apps-to-surge-7ee763db2235"&gt;Medium&lt;/a&gt; on January 14, 2018.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>deployment</category>
    </item>
  </channel>
</rss>
