diff --git a/week-0/day-3/my_todo_app/todo_app/.__init__.py.swp b/week-0/day-3/my_todo_app/todo_app/.__init__.py.swp
new file mode 100644
index 00000000..702aa096
Binary files /dev/null and b/week-0/day-3/my_todo_app/todo_app/.__init__.py.swp differ
diff --git a/week-0/day-3/my_todo_app/todo_app/__init__.py b/week-0/day-3/my_todo_app/todo_app/__init__.py
index 86fb09d8..cf560876 100644
--- a/week-0/day-3/my_todo_app/todo_app/__init__.py
+++ b/week-0/day-3/my_todo_app/todo_app/__init__.py
@@ -3,16 +3,6 @@
from flask import Flask
from flask import request
-from flask import render_template
-
-# our fake db
-todo_store = {}
-todo_store['depo'] = ['Go for run', 'Listen Rock Music']
-todo_store['shivang'] = ['Read book', 'Play Fifa', 'Drink Coffee']
-todo_store['raj'] = ['Study', 'Brush']
-todo_store['sanket'] = ['Sleep', 'Code']
-todo_store['aagam'] = ['play cricket', 'have tea']
-
def create_app(test_config=None):
# create and configure the app
app = Flask(__name__, instance_relative_config=True)
@@ -23,50 +13,33 @@ def create_app(test_config=None):
except OSError:
pass
- def select_todos(name):
- global todo_store
- return todo_store[name]
-
- def insert_todo(name, todo):
- global todo_store
- current_todos = todo_store[name]
- current_todos.append(todo)
- todo_store[name] = current_todos
- return
-
- def add_todo_by_name(name, todo):
- # call DB function
- insert_todo(name, todo)
- return
-
+ # a simple page that list my todos
def get_todos_by_name(name):
- try:
- return select_todos(name)
- except:
- return None
-
+ if name=='raj':
+ return ['Eat','Sleep','Repeat']
+ elif name=='shivang':
+ return ['Brush','Study']
+ elif name=='manish':
+ return ['sleep','code']
+ else:
+ return []
- # http://127.0.0.1:5000/todos?name=duster
@app.route('/todos')
def todos():
- name = request.args.get('name')
- print('---------')
+ name=request.args.get('name')
+ print('------')
print(name)
- print('---------')
+ print('------')
- person_todo_list = get_todos_by_name(name)
- if person_todo_list == None:
- return render_template('404.html'), 404
- else:
- return render_template('todo_view.html',todos=person_todo_list)
+ todo_l=get_todos_by_name(name)
+ return todo_view(todo_l)
+ def todo_view(todos):
+ the_view = 'List of my todos:' + '
'
+ for todo in todos:
+ the_view += ( todo + '
' )
- @app.route('/add_todos')
- def add_todos():
- name = request.args.get('name')
- todo = request.args.get('todo')
- add_todo_by_name(name, todo)
- return 'Added Successfully'
+ the_view += '---LIST ENDS HERE---'
+ return the_view
return app
-
diff --git a/week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-36.pyc b/week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-36.pyc
index 7f86b4e6..c27428d6 100644
Binary files a/week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-36.pyc and b/week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-36.pyc differ