Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'app_ctx' from 'flask.globals' #227

Open
paddy960609 opened this issue Nov 17, 2022 · 1 comment
Open

ImportError: cannot import name 'app_ctx' from 'flask.globals' #227

paddy960609 opened this issue Nov 17, 2022 · 1 comment

Comments

@paddy960609
Copy link

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!

@Fazal9638
Copy link

Hi,

Have you got any solution for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants