A simple primer example of Flask framework in python

  • 2020-04-02 14:43:41
  • OfStack

This example demonstrates the simple use of the Flask framework in python. Share with you for your reference. The details are as follows:

Flask framework is a simple sample to start with. If you are learning the Flask framework, you can refer to the following startup code, which will output "hello world" on the web page.


import os
# Using Flask since Python doesn't have built-in session management
from flask import Flask, session
app = Flask(__name__)
# Generate a secret random key for the session
app.secret_key = os.urandom(24)
@app.route('/')
def index():
 return "Hello world"
if __name__ == '__main__':
 app.run( 
    host="0.0.0.0",
    port=int("80")
 )

I hope this article has helped you with your Python programming.


Related articles: