Error message for no reason

I am just getting started with backend development with flask and it is showing an error message
12 Replies
Jochem
Jochem2y ago
not sure I'll be able to help, I barely use python and never used flask, but the error is referring to something going on in __init__.py inside the website folder can you paste the contents of that in a code block instead of a screenshot? They're much easier to work with
rishit
rishit2y ago
from website import create_app

app = create_app()

if __name__ == '__main__':
app.run(debug=True)
from website import create_app

app = create_app()

if __name__ == '__main__':
app.run(debug=True)
from flask import Flask

def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = 'idk'

from .views import views
from .auth import auth

app.register_blueprint(views, url_prefix = '/')
app.register_blueprint(auth, url_prefix = '/')

return app
from flask import Flask

def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = 'idk'

from .views import views
from .auth import auth

app.register_blueprint(views, url_prefix = '/')
app.register_blueprint(auth, url_prefix = '/')

return app
this is init
Jochem
Jochem2y ago
are you following a tutorial?
rishit
rishit2y ago
yes tech with tim
Jochem
Jochem2y ago
can you link it?
rishit
rishit2y ago
Tech With Tim
YouTube
Python Website Full Tutorial - Flask, Authentication, Databases & More
In this video, I'm going to be showing you how to make a website with Python, covering Flask, authentication, databases, and more. The goal of this video is to give you what you need to make a finished product that you can tweak, and turn into anything you like. We're going to also go over how you create a new user's account, how you store those...
Jochem
Jochem2y ago
and the contents of views.py? can you paste the contents of your views.py
rishit
rishit2y ago
from flask import Blueprint

views = Blueprint('views', __name__)

@views.route('/')
def home():
return "<h1>Test</h1>"
from flask import Blueprint

views = Blueprint('views', __name__)

@views.route('/')
def home():
return "<h1>Test</h1>"
Jochem
Jochem2y ago
can you try removing the second register_blueprint line?
app.register_blueprint(auth, url_prefix = '/')
app.register_blueprint(auth, url_prefix = '/')
this one
rishit
rishit2y ago
tysm it worked
Jochem
Jochem2y ago
you probably have to have unique url_prefix values, maybe that's a new feature in the most recent version of flask or something... if this works, it'll probably also work to change the prefix for the auth one to '/auth/' if it doesn't, I noticed one of the comments on that youtube video said they had to remove the contents of url_prefix, so maybe using url_prefix = '' for views might help too
rishit
rishit2y ago
k thanks
Want results from more Discord servers?
Add your server