Embark on a magical adventure as we install Flask and enter the mystical world of FlaskMagic.
Choose a location on your computer for your Flask project. Create a new folder and name it "FlaskMagic."
- Open the command prompt or terminal on your computer.
- Navigate to the "FlaskMagic" project folder.
- Create a virtual environment by running this command:
python -m venv venv
Activate the virtual environment. Use the appropriate command
powershell
venv\Scripts\Activate.ps1
You will see the virtual environment activated.
Make sure the virtual environment is activated. Install Flask by running this command:
pip install Flask
Create a new file inside the "FlaskMagic" project folder and name it "app.py." Open "app.py" in a text editor. Copy and paste the following code into "app.py":
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Welcome to FlaskMagic!'
if __name__ == '__main__':
app.run()
Save the "app.py" file. Make sure the virtual environment is still activated. In the command prompt or terminal, run this command:
python app.py
The Flask development server will start running.
- Take a screenshot and provide a description of the Flask application running on your computer.
- Submit the screenshot as instructed by your instructor.
Congratulations! You have successfully installed Flask, set up a virtual environment, and created a magical Flask application. Enjoy the journey into the world of FlaskMagic!