Someone tell me where I'm wong

from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

app = Flask(__name__)

    'sqlite:///test.db'  # everything gonna be stored in test.db file
db = SQLAlchemy(app)

class Todo(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    content = db.Column(db.String(200), nullable=False)
    completed = db.Column(db.Integer, default=0)
    date_created = db.Column(db.DateTime, default=datetime.utcnow)

    def __repr__(self):
        return '<Task %i>' %

def hello_world():
    return render_template('index.html')

RuntimeError: Working outside of application context.

This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.

Do you have a question? This looks like it was just copy-pasted somewhere without any context or formatting.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.