How to create a website in Python - Python Flask tutorial - First basic website

How to create a website in Python - Python Flask tutorial - First basic website

Python is a very popular language right now. Many big companies are using it. Python is used in most of the fields. You can create softwares, basic games as well as websites in Python. In web development, Python's libraries are considered very good for making backends. Even companies like Netflix use Python in their backend.

Basically, there are two main Python libraries, with which you can learn wen development and create a backend for your site. First is Flask, the other is Django. Flask is a little simple.

Here I will show how you can make your first Python website with Flask...

Process

  • Install the Flask library, by running the command pip install flask in your terminal.
  • Then you are ready for making your first Flask App
  • To get your first app, Create a new file and paste the below code. This is the basic structure of a Flask application.

The Code

from flask import Flask, app
import flask

app = Flask(__name__)

@app.route("/")
def index():
    return "Just testing! Hello Sir! I am a web app"

if __name__ == "__main__":
    app.run(host="127.0.0.1", port=8080, debug=True)

Congratulations, you have made your first Flask app.

Now open the terminal and run the command flask run



Previous Post:
Make your own Web Browser in Python using PyQt5. PyQt5 is a very powerful Python framework to make modern GUIs. With help of Python PyQt5 QtWebWidgets, it is very easy to amke your own custom web browser with a few lines of code.

PyQt5 Basic code


import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class MainWindow(QMainWindow):
    def __init__(self):
        # Main Window
        super(MainWindow, self).__init__()
        self.showMaximized()

app = QApplication(sys.argv)
QApplication.setApplicationName("Browser")
window = MainWindow()
app.exec_()



PyQt5 Browser code using QtWebEngine



4 Comments

  1. More python tutorials please

    ReplyDelete
  2. Please be a little consistent

    ReplyDelete
  3. Bhai ek mahina ho gya almost last post ke baad... Where are you?

    ReplyDelete
  4. Will you continue the Flask tutorial series?

    ReplyDelete