In this video tutorial, we will be showing you how to get started with Flask and build a web application. Flask is a python microenvironment designed to be lightweight and offers you the freedom to create web applications without limitations on the modules and packages you want to use and, the methods and structure you want to follow.
pip 3 install virtual env virtualenv --python=python3
python-tutorial source bin/activate pip
Add the following code to the file flask-tut.py:
# Import the Flask package from flask import Flask
# Initialize Flask app = Flask(__name__)
# Define the index route @app.route("/") def index(): return "Hello from Flask!"
# Run Flask if the __name__ variable is equal to __main__ if __name__ == "__main__": app.run()
:wq to save the file.
Now execute the file by running:
python3 flask-tut.py (flask_tutorial) Johns-MBP:flask_tutorial john$ python flask_tut.py * Serving Flask app "flask_tut" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off< * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) All requests and response codes will be logged to the output from the running server in the terminal.
The related article for this video can be found here: https://www.liquidweb.com/kb/getting-started-with-flask/
For more information about this and other topics, visit us at https://www.liquidweb.com/kb/ or https://www.youtube.com/user/LiquidWebInc
Check out our full line of applicable products here! https://www.liquidweb.com/products/
Video by: John Long