Everything about flask --> by myCODEnotein
Creating a virtual environment (Optional)
Note that by creating virtual environment you need to install all the required modules again. Also everything you do in the terminal must be done after activating the virtual environment
Run the following command in terminal
python -m venv name_of_environment
# Example:
python -m venv virt
Activating a virtual environment
# In git bash
source name_of_environment/Scripts/activate
# In this example:
source virt/Scripts/activate
# In cmd
name_of_environment\Scripts\activate
# In this example:
virt\Scripts\activate
Deactivating a virtual environment
just run the command:
deactivate
Installation of flask
pip install flask
Starting with coding and Starter code
Firstly let us create a file named app.py
in the current directory.
And then write/paste the below code in it.
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return 'myCODEnotein is best'
if __name__=="__main__":
app.run(debug=True) # True only while development