Hackforge Academy

Category: python

creating your first flask application

Published on 30 Sep 2026

Explanation

Import Flask and create an application instance using the Flask class.

Code:

from flask import Flask

app = Flask(__name__)

Explanation

Create a route using the @app.route decorator and return a response.

Code:

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

Explanation

Run the application using Flask's development server.

Code:

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

Explanation

The browser sends a request to the root URL and Flask executes the function mapped to that route.

Code:

GET /
  |
  v
home()
  |
  v
'Hello Flask!'

Explanation

Debug mode automatically reloads the development server when code changes and provides debugging information during development.

Code:

app.run(
    debug=True,
    host='127.0.0.1',
    port=5000
)

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community