-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (25 loc) · 911 Bytes
/
app.py
File metadata and controls
32 lines (25 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///todo.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class Todo(db.Model):
sno = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(200), nullable = False)
desc = db.Column(db.String(500), nullable = False)
date_created = db.Column(db.DateTime, default=datetime.utcnow)
def __repr__(self) -> str:
return f"{self.sno} - {self.title}"
@app.route("/")
def dashboard():
todo = Todo(title="My first task",desc="Start doing flask!!")
db.session.add(todo)
db.session.commit()
return render_template("home.html")
@app.route("/task")
def task():
return render_template("addTodo.html")
if __name__=="__main__":
app.run(debug=True)