Simple Flask sample

Just wanna to create a very simple Flask application in a single python source file:

simple.py

from flask import Flask
application = Flask("simple")
@application.route("/")
def index():
return "Hello World"


To run this Flask application, run the following:
  • export FLASK_APP=simple.py
  • flask run
If you want to put this application in a Docker container, you need to bind to 0.0.0.0:
  • flask run --host 0.0.0.0

Now, navigate "http://localhost:5000" to see the word "Hello World" displayed on the browser.

Comments

Popular posts from this blog