Flask Hello World: Setting up a python virtual environment (venv) in VS Code & installing Flask
ฝัง
- เผยแพร่เมื่อ 12 ก.ย. 2024
- In this video we work in Visual Studio Code that already has the basic Python Extensions. We run python -m venv venv to establish a virtual environment. Next, we made sure the the current user had the appropriate script running permissions in PowerShell (this was a Windows system). Then we activated the virtual environment and ran the command pip install Flask. After that we created a .py file in the virtual environment and added the basic "Hello World" code to have Flask act as a virtual web server and serve up a very simple page. We invoked the flask app from the command line (terminal) and accessed the resulting page.
thank you so much! I have been struggling with this
While I know it works, should project files be placed in the virtual environment folder (venv in this case)? Isn't this folder more of a throwaway folder that can be rebuilt at any time (and reload requirements from a requirements.txt file). Putting project files in it seems to clutter what would be part of the distribution files and development files.
can you make a video explaining what goes inside the include folder. and also when making .gitignore file what folders and files should someone hide?
thank you so much !
Thank you
i am getting error message stating this : Usage: flask run [OPTIONS]
Try 'flask run --help' for help.
Hard to say. Did everything work up until using "flask run"? Do you have a virtual environment? Is it activated? Did the flask installation work? Is your hello.py file located in the virtual environment? Is your terminal location the same as the virtual environment (venv) location?
The following link offers some suggestions and alternatives
www.twilio.com/en-us/blog/how-run-flask-application
I have seen flask app's started in VS Code by starting with Run and Debug on the left-hand side of Code and then choosing flask from the drop-down and hitting Enter on the keyboard.
Good luck.
@@thomasblum9803 thanks for the immediate response sir, I just created the fie in Scripts instead of creating it in venv ! great simple tutorial sir. Thank you !
www1.lasalle.edu/~blum/c341wks/Python_Flask_Hello_World.zip
thank you