Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

flask No application found. Either work inside a view function or push an application context

# This file initializes your application and brings together all of the various components.

# TL;DR: db.create_all(app=app)

from flask import Flask
from .views import mainRoutes	# This just imports my URL-routes
from .extensions import db		# Creates db in another file

app = Flask(__name__)

app.config.from_pyfile('../settings.py')	# Separate file to configure your app

db.init_app(app)
db.create_all(app=app)			# THIS IS THE CRITICAL SOLUTION

app.register_blueprint(mainRoutes)

from DatabaseTest import views # import down here to prevent circular imports
Comment

PREVIOUS NEXT
Code Example
Python :: keras conv2d 
Python :: python is instance 
Python :: merge keep left index 
Python :: rename all columns 
Python :: .items() python 
Python :: ImportError: No module named _bootlocale 
Python :: check list for duplicate values python 
Python :: condition in python 
Python :: join tuple to string python 
Python :: queue in python 
Python :: python os.path.join 
Python :: python tobytes 
Python :: django model query join 
Python :: index duplicates python 
Python :: Appending rows to a DataFrame 
Python :: how to print in python 
Python :: head first python by paul barry pdf 
Python :: python filter list with lambda 
Python :: python animation 
Python :: reply to a message discord.py 
Python :: array creation in numpy 
Python :: session in django 
Python :: authentication views django 
Python :: discord.py read custom status 
Python :: multiple inputs in one line- python 
Python :: pyqt5 drop down menu 
Python :: python how to check if a dictionary key exists 
Python :: get data from model with field name in django 
Python :: django generate openapi schema command line 
Python :: python regex match until first occurrence 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =