Flask Web App Tutorial

Flask Web App Tutorial | DarchumsTech

🚀 Flask Web App Tutorial

Learn how to build a simple web app using Flask and Python

🔧 What is Flask?

Flask is a lightweight Python web framework that makes it easy to build simple web applications quickly. It’s great for beginners and professionals alike.

📦 Step 1: Install Flask

# Install Flask via pip
pip install flask

💻 Step 2: Create Your Flask App

# app.py
from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Hello, Flask!"

if __name__ == "__main__":
    app.run(debug=True)

▶ Step 3: Run the App

In your terminal, run:

python app.py

Visit http://127.0.0.1:5000 in your browser. You should see “Hello, Flask!”

🌐 Step 4: Add HTML Templates

# Create a folder called 'templates' and add index.html




  My Flask Web App


  

Welcome to My Flask Web App

# Update app.py
from flask import Flask, render_template

app = Flask(__name__)

@app.route("/")
def home():
    return render_template("index.html")

✅ Summary

  • Flask helps you build web apps using Python.
  • You define routes with @app.route.
  • You can render HTML files from the templates/ folder.

📌 Tips for Deployment

  • Use Gunicorn or uWSGI for production
  • Host on platforms like Heroku, Render, or Railway
  • Never use debug=True in production

© 2025 DarchumsTech. All rights reserved.

Comments