Python Flask Hello World Example

from flask import Flask

app = Flask(__name__)

@app.route('/', methods = ['GET'])
def root():
    message = 'Hello, World!'
    return message

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000, debug=False)

Skeleton code for a python flask application

BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. Import the Flask class and create an instance of the Flask class.
2. Define a route to match the URL - in this case the root directory of our web server.
3. Define the view using a Python function, which returns a response, in this case some

Snippet By Ruan Bekker

ยท

Created June 2nd, 2022

ยท

Report Snippet