Press "Enter" to skip to content

Python for Web development – How to develop a Website using Python?

1

Python is a beginner’s favorite programming language, We use python for different purposes like to build software, servers. Python is also used for web development as a server to create a web application.

Python is created by Guido van Rossum in 1991.

We can develop website on Python by using its Web frameworks:-

  • Django
  • Flask
  • web2py
  • cherryPy and more

Here we talk about two Web Framework of python “Django” and “Flask”.

Flask:- Flask is a most basic and micro web framework of python for web development, flask does not come with basic functionality like form validation, database interaction, it uses third parties library for functionalities. Flask is the basic framework use for developing tiny web applications. Some of the popular companies using flasks are:- Netflix, Reddit, Uber.

What you have to learn before start with flask for Web Development:-

  • Before starting with flask you have a basic knowledge of python.
  • For web development, you must know HTML, CSS for templating the user interface.
  • You must have any database knowledge like MySQL, MongoDB, and idea about how module, logic, and understanding about the workflow of the module.
  • Python is installed in your machine.
  • Install pip in your computer, PIP is a python package manager.
  • Now install flask by using this command "pip install flask"
  • Now create a file “app.py” for a small application on the flask.
from flask import Flask
app = Flask(__name__)  
 
@app.route('/home')  
def home():  
    return "Welcome to TechLifeDiary!";  
  
if __name__ == "__main__":  
    app.run(debug = True)  

We have to import flask everytime and we will import any other libraries as per project requirement.

@app.route('/home') this code means here we create a routing for the project.

def home(): is defining the route “home” that what functionality should be here happen or visible to the interface.

Now in command prompt write "python app.py"

Open url “localhost:5000/home” in a browser, you will see the below screen.

Django:- Django a python framework that’ is design for the development of web applications on python. Django has many modules created to make web development in a very short period of time. The great feature of Django is that the automatic admin interface that it creates interface by itself and it have own management tool that helps the developer to just write a few template coding for rapid development.

Check out this to setup Django framework from scratch

Python Web development tutorial using Flask
How to export a query result in excel CSV from MySQL PHPMyAdmin
  1. This is a neat as well as beneficial bit of facts online web development tools. I am just pleased you shared this useful information and facts about. Be sure to stay you up to date like that. Appreciate your revealing.

Comments are closed.