Learn Flask for Python - Full Tutorial
Why Stack Overflow recommends it
Stack Overflow users link it as the beginner Flask tutorial they are following, and many questions come from learners who got stuck at its virtualenv and database setup steps.
Recommended by 4 people across 4 different months, 2019 to 2023.
What it is
A 47-minute freeCodeCamp crash course by Jake Rieger that introduces Flask, the Python micro web framework. It builds a to-do list app with templates, forms and a SQLAlchemy SQLite database, starting from setting up a virtual environment.
What people said
Recommends Chance · 2019-11 · Stack Overflow · on “How to setup a virtual environment for python in Visual Studio Code using the command line”
I am a very new programmer trying to learn Flask now that I've learned the basics of Python. I am following this tutorial [this video] ... I am stuck at 5:46. The tutorial, as well as documentation on several other websites, explains to type in the following command: \env\Scripts\activate.bat for Windows, and they suggest using: source env/bin/activate for Mac. This is what I get in return: \env\Scripts\activate.bat : The term '\env\Scripts\activate.bat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + \env\Scripts\activate.bat + ~~~~~~
Recommends Maxim King · 2020-08 · Stack Overflow · on “website content overlapping the navigation bar”
Have you tried adding something as simple as a <br> tag? Then the text will be pushed down and not overlap. (Edited) Trying this newer tutorial this is a year old so the components won’t be out of date this mite also answer some of your questions about Flask. [this video]
Recommends Klarner · 2020-09 · Stack Overflow · on “can't find '__main__' module”
This is probably because you are using anaconda3 as your main interpreter. I have Anaconda installed in my system, and whenever I use it as the main interpreter while using flask, there were many errors. I would recommend you to not use Anaconda and use a virtual environment and use "vanilla" python. pip install virtualenv Unlike other frameworks, flask requires a bit of set up to do things. And since it requires set up, a virtual environment is needed. So, what does this virtualenv do? it does what the name entails, create a virtual environment through the process of installing python in a sub folder and other necessary things that you might need within your project. Once done, create a fol
Recommends Mushroomator · 2022-03 · Stack Overflow · on “How to send information to the backend in React.js?”
And you are also sending a POST request from the frontend to the `guess` endpoint? Those two must match. Don't put the `methods=["POST"]` in your `/` route. A normal request to load a website is always a `GET` request. You might wanna watch some tutorial like this one [this video] to get your head around this.
Cites ejbee3 · 2020-02 · Stack Overflow · on “New to Python and using Flask, my POST method isn't rendering in my local environment, getting a 302 Http status response”
I'm doing a flask tutorial on [this video] , and I can't get my app to show new to do's in the list when I post them to the database. There's no error, but I'm getting a 302 http response. My code is the same to the tutorial, so I am having trouble figuring out where the error is coming from. I believe the task is not actually getting posted to the database properly, but I'm not sure I know enough about Python to confirm. In app.py: from flask import Flask, render_template, url_for, request, redirect from flask_sqlalchemy import SQLAlchemy from datetime import datetime app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db' db = SQLAlchemy(app) class Todo(db.Model): id =
Cites Parth Patel · 2020-12 · Stack Overflow · on “Trying to make a .db file with flask”
I was following a tutorial on youtube. At 20:00 they ask to create .db file. They go to a python shell and type: from main import db db.create_all() When I try importing db it comes up with an error. The error says that there is no module called flask, but I have already installed flask and imported it. How do I get it to create the .db file? This is the error: This in the code: The tutorial: [this video]
Cites JackJTR · 2021-01 · Stack Overflow · on “moduleNotFoundError: No module named 'flask' (SQLAlchemy)”
I am new to the python and flask. I am watching a you tube tutorial and i am stuck at 20:05 where he run the code "from app import db". I follow exactly the step he taught but yet I still face this problem.Below are the program I type and at the terminal there it shows the error. The Program: from flask import Flask, render_template, url_for from flask_sqlalchemy import SQLAlchemy from datetime import datetime app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db' db = SQLAlchemy(app) class Todo(db.Model): id = db.Column(db.Integer, primary_key=True) content = db.Column(db.String(200), nullable=False) #This is to set the character the person input date_created = db
Cites Mario Campopiano · 2021-03 · Stack Overflow · on “AttributeError: can't set attribute when trying to create database with sqlalchemy”
trying to follow this tutorial from freecodecamp intro to flask video: [this video] The relevant bit of the video starts at around minute 19 This is my code: from flask import Flask, render_template from flask_sqlalchemy import SQLAlchemy from datetime import datetime app = Flask(name) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sqlite.db' # initialize the database with the settings from app db = SQLAlchemy(app) class Budget_Item(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), nullable=False) cost = db.Column(db.Float, nullable=False) date_created = db.Column(db.DateTime, default=datetime.utcnow) recurring = db.Column(db.Boolean, nullable=False) due_
Cites Snake_py · 2021-11 · Stack Overflow · on “Creating a frontend program for a machine learning program (help)”
So this is a very general question, hence it is hard to answer. I will give you a short pointer on how to achieve this, please note that there are many ways and I am trying to give you the easiest. App requirements I assume: The look is not important, functionality is the base Any framework can be used A beginner should be able to do this. - hence js frameworks will be avoided. I've come to the answer that the front end will be html and some CSS and will connect to some API program that acts as the middle man between the front end and the backend programs. Yes, this is somewhat correct, you most likely will sprinkle some JS into the frontend, but it is not required and everything is possible
Cites Selman Genç · 2022-03 · Stack Overflow · on “Flask module not found even though it's installed”
I am following this [this video] python tutorial on flask, I have created the virtual environment and the code runs fine without issues. But when I open an interactive shell inside the virtual environment and type: from app import db I get this error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Repo\flask todo app\app.py", line 1, in <module> from flask import Flask, render_template ModuleNotFoundError: No module named 'flask' When I try to install flask it says it's already installed, I am not sure what I am doing wrong? The full console output: (venv) C:\Repo\flask todo app>python3 Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit