DEV Community

Jesse Orshan
Jesse Orshan

Posted on

Easily Deploying a Flask App w/ WayScript (for free)

In this tutorial, I am going to walk through the basics of setting up and deploying a flask app from scratch using WayScript (a free deployment platform).

Step 1 - Create a WayScript project.

WayScript projects are referred to as lairs, these are just flexible cloud based development environments for you to run and test your code.

Step 2 - Open up the code editor

Image description

Click on the develop tab to open your code editor on WayScript. In the editor, you have the following panels:

  1. Editor
  2. Terminal
  3. Triggers
  4. Processes

I'll cover some of these but for now make sure you have the Editor and Terminal views open (like in the image above).

Step 3 - Install Flask

In the Terminal, input the following two commands:

pip install flask
pip freeze > requirements.txt
Enter fullscreen mode Exit fullscreen mode

Step 4 - Setup Your Files

Now, we are going to add the first file for building your server. In the Terminal, type the following command:

touch app.py
Enter fullscreen mode Exit fullscreen mode

Once done, you should see the file app.py appear in the Code Editor.

Image description

Step 5 - Edit your app.py File

Here is the initial code for your app.py file:

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    return {"Message" : "Hello World"}
Enter fullscreen mode Exit fullscreen mode

Step 6 - Set Up Your Deployment

In order to deploy your app, you need to configure an deploy Trigger.

In your Triggers panel, select a Deploy trigger and fill in the following details:

Command To Run: flask run --port 8080 --host 0.0.0.0

Port: 8080

Image description

Step 7 - Deploy your app!

Once the Trigger is set up, go the Deploy tab and press deploy! Now you app is good to go. You can view the app by referencing the URLs in your Endpoints tab.

Image description

Under endpoints, hit the prod url to see your endpoint working!

Image description

Note - in order to run your server in the dev mode, you must press the play button on the trigger you set up

Other Notes - Built in logs, processes, and alerts

There are other tabs for viewing logs, your server running, and you can set up automatic alerting if your app has any errors.

Happy coding!

Top comments (0)