Skip to content

Instantly share code, notes, and snippets.

@shinysu
Created April 17, 2021 10:29
Show Gist options
  • Save shinysu/b5277aa10136aa6951f4392f3042b367 to your computer and use it in GitHub Desktop.
Save shinysu/b5277aa10136aa6951f4392f3042b367 to your computer and use it in GitHub Desktop.
todolist
from flask import Flask, render_template
app = Flask(
__name__,
template_folder = 'client/templates'
)
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)
import sqlite3
sql_query = """
CREATE TABLE IF NOT EXISTS Todo(
id INTEGER PRIMARY KEY,
task TEXT,
complete boolean
);
"""
def execute_query(sql_query):
with sqlite3.connect("todo.db") as conn:
cur = conn.cursor()
result = cur.execute(sql_query)
conn.commit()
return result
if __name__ == '__main__':
execute_query(sql_query)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>TodoList</title>
</head>
<body>
<h1> ToDo List</h1>
<form>
<label>Add a new item </label>
<input type="text" name="todoitem">
<input type="submit" >
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment