My personal repo for building web applications with Flask. Nothing fancy - just teaching myself something new.
Following along the courses provided by Anthony H. located here
Code and tutorials also on GitHub and YouTube - highly recommended!
This Flask project was built on Windows 10 using a virtual environment. See the following guides:
Pipenv & Virtual Environments - see Lower level: virtualenv
Creation of virtual environments - see instructions for Windows
Of course, you can do the same in MacOS or Linux following instructions for those platforms. Also, pipevn if you prefer.
Initialize virtual environment
c:\>python -m venv c:\path\to\env
Activate virtual environment
C:\Users\SomeUser\project_folder> env\Scripts\activate
To stop the virtual environment
deactivate
Launch Flask - see Flask Quick Start
flask run
Tip: If there are .env or .flaskenv files present (as in the "Flask for Beginners" tutorial), run command "pip install python-dotenv" to use them.
For your first time with Flask, most tutorials start with Hello World like this:
@app.route('/')
def index():
return 'Hello World!'
Beyond returning a line of text, your next step is to add proper HTML to each page.
@app.route('/')
def index():
return '''
<html>
<body>
<p>Welcome to My Flask App</p>
<form>
<p><input name="number1" /></p>
<p><input name="number2" /></p>
<p><input type="submit" value="Do calculation" /></p>
</form>
</body>
</html>
'''