DEV Community

Suman Naskar
Suman Naskar

Posted on

Build a server with python flask

Introduction
Flask is a lightweight and easy-to-use web framework for Python. It's great for beginners who want to build a simple server. In this guide, we'll walk you through the steps to create a basic Flask server.

STEP-1
Install flask

pip install flask
Enter fullscreen mode Exit fullscreen mode

STEP-2
Create a new folder for your project. You can name it anything you like, for example, flask-server.

STEP-3
Inside your project folder, create a new file named app.py. This is where we will write our server code.

STEP-4
Write Your Flask Server Code
Open app.py in a code editor and write the following code:

from flask import Flask

app = Flask(__name__)

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

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

Enter fullscreen mode Exit fullscreen mode

STEP-5
Run your flask server

python app.py
Enter fullscreen mode Exit fullscreen mode

Top comments (0)