β Cloud-Based Development: A Beginner's Guide to Building Python Flask Applications with Deployment.β
Getting Started π¨π½βπ»
To begin, ensure you have a Linux environment set up. If you're using Windows 10, install Windows Subsystem for Linux (WSL) and configure an instance, as outlined in my previous article.
File Extensions Overview
Familiarize yourself with common file extensions:
π΅ Python: .py
π΅ JavaScript: .js
π΅ C#: .cs
π΅ Ruby: .rb
π΅ PHP: .php
Our Focus
In this tutorial, we'll concentrate on building and deploying Python application, utilizing .py
Deployment Guide: Python Application.
Section A
Create an Instance
Follow the detailed instructions in my previous article to create an instance on AWS EC2: Post
Refer to Section A for the step-by-step guide π€.
Section B
Connect to Your Server π€
Once your instance is set up, connect to your server by following Section B in the same article: Post
Stay Tuned π―
For the pictorial deployment guide of Python application.
Section C
Deployment Phase
Step: Update Virtual Serverππ.
Step 2: Verify Python Installation - Check Version.
Step 3: Create 'apps' Directory and Verify.
Step 4: Access 'apps' Folder, Create a New File and Open for Editing.
Step 5: Add Your Code to the Newly Created File
Step 6: Save & Exit Nano Editor (Ctrl x, Y, Enter)
Step 7: Review File Contents.
Step 8: Execute Python Code.
Step 9: Set Up Virtual Environment.
(1. You can see itβs not install) (2. You can see it is not install) (3. Install virtual environment {venv})
Check if Virtual Environment is Installed.
python3 -m venv
If not installed:
sudo apt-get install python3-venv
Step 10: Run and Activate venv
To activate:
Source Jamiu/bin/activate
Step 11: Install Flask framework Using pip.
pip install flask
Step 12: List packages installed in the virtual environment.
Step 13: Create app.py and Open in Nano Editor.
Insert this code:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, This is my first Live Python Flask app!</p>"
Step 14: Execute app.py with Python and Start Flask Server.
Flask app is running, but only accessible internally.
Step 15: Go Live - Make Application Accessible to External Users.
Step 16: Verify Application Status - Running and Active.
Congratulations! π You've Successfully Deployed Your First Flask Application in Python. πΊπ½πΊπ½πΊπ½
Conclusion:
We've reached the end of this installment. Keep an eye out for my upcoming article, arriving in the next few daysπππ.
Top comments (0)