Building a Website Using Flask (Python): Part 1

Posted by

Creating website with Flask(Python) part 1

Creating website with Flask(Python) part 1

Flask is a micro web framework written in Python. It is lightweight and easy to use, making it a popular choice for building web applications. In this article, we will discuss how to create a website with Flask.

Getting Started

Before we start building our website, we need to install Flask. If you haven’t already installed it, you can do so by running the following command in your terminal:

pip install Flask

Creating the App

Once Flask is installed, we can create a new app using the following code:


from flask import Flask
app = Flask(__name__)

@app.route('/')
def index():
return 'Hello World'

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

This code creates a basic Flask app with a single route that returns ‘Hello World’ when the root URL is accessed.

Running the App

To run the app, you can save the code in a file called app.py and then run the following command in your terminal:

python app.py

This will start a local server, and you can access your website by navigating to http://localhost:5000 in your web browser.

Conclusion

Now that you have a basic understanding of how to create a website using Flask, you can start building more complex applications. In the next part of this series, we will discuss how to create dynamic routes and templates for your Flask app.

0 0 votes
Article Rating
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@dmitriynikolaev6361
11 months ago

Смотрю и плачу 😢. Год назад видел ролики с данного канала. За прошедший год в жизни все поменялось, стало как-то грустно, жил в надежде на что-то. И вот я увидел этот ролик и понял, мне не хватало именно его, спасибо моему рыжому автору за этот шедевр ❤️

@yari_la
11 months ago

Ничего себе