Skip to main content

[Tutorial ~ Step by Step] Trying to learn about web programming with Flask

Hello guys, Welcome to my personal blog.
In this tutorial, I want to share some knowledge of Flask.

First of all, I would like to introduce myself. My name is Nyamkhuu. I am a software developer. I am writing code in Java, almost every day. But  I want to learn a python programming language. So, I decided to start a blog while learning. If you don't know about the Flask, don't worry. I am a beginner too. 😃
Before start coding, I would try to explain through my words what is flask. The flask is a web application framework but lightweight more than the Django. Then, easy to use and learn, in my opinion. But now, Let's see the official definition.
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks.

If you want to visit the official website of the flask. click there 

So,  Let's get start coding 😃😃
First, We should create a project folder and virtual environment folder within:

$mkdir project_name
$cd project_name
$python3 -m venv env

On windows:

$py -3 -m venv env

So, we should activate our virtual environment.

$source env/bin/activate

That's it our configure. We already begin to write some code.
So, you can use your favorite code editor. In my case, I want to use Vim. :D
First, we should create a new python script file. Just save it as First.py or something similar.
Here's my First.py:
from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def about():
    return 'Hello world!, this is my first blog'

if __name__ == '__main__':
    app.run(debug=True)
After, open your terminal or cmd. Then, write this command.

$python First.py
By default, Flask runs on localhost:5000
That's it my first tutorial. See you guys. Enjoy :D :)

Comments

Popular posts from this blog

Software engineer vs programmer

Hello guys many lot of people ask me about what's difference between software engineer and programmer? Today, I am about to talk that topic. Many people confused in computer science topics. For instance, above question. Let's go inside. Programmer: These kind of people are never make new things as well as algorithms, new library or plugin and who are only write code as requirements, in my opinion. Perhaps, these are daunt from working own brain more than daily usage of brain. Software engineer: These kind of people are always think about how to diminish execution time or time complexity. In other words, these are always find more efficient way which is solving problems. These have experience more than programmers, I think. I took up data structure implementing last year.  The reason is just I want to improve my problem solving skill. Of course, I practice every day. But it isn't means I am expert. If you want to become software engineer, this isn't just write ...