ImportError: cannot import name 'app_ctx' from 'flask.globals'
- Dominant language
- C#
- Stars
- 8k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
I kept getting this error every time I ran my code and stack overflow solutions didn't help me either so I figured I would come here for help.
My main.py is as follows:
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
##Connect to Database
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///cafes.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
##Cafe TABLE Configuration
class Cafe(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(250), unique=True, nullable=False)
map_url = db.Column(db.String(500), nullable=False)
img_url = db.Column(db.String(500), nullable=False)
location = db.Column(db.String(250), nullable=False)
seats = db.Column(db.String(250), nullable=False)
has_toilet = db.Column(db.Boolean, nullable=False)
has_wifi = db.Column(db.Boolean, nullable=False)
has_sockets = db.Column(db.Boolean, nullable=False)
can_take_calls = db.Column(db.Boolean, nullable=False)
coffee_price = db.Column(db.String(250), nullable=True)
@app.route("/")
def home():
return render_template("index.html")
## HTTP GET - Read Record
## HTTP POST - Create Record
## HTTP PUT/PATCH - Update Record
## HTTP DELETE - Delete Record
if __name__ == '__main__':
app.run(debug=True)
Thanks!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.