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..d28404ae 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 @@ -1,17 +1,7 @@ import os 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 @@ -22,51 +12,28 @@ def create_app(test_config=None): os.makedirs(app.instance_path) 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 - - def get_todos_by_name(name): - try: - return select_todos(name) - except: - return None - - - # http://127.0.0.1:5000/todos?name=duster - @app.route('/todos') - def todos(): - name = request.args.get('name') - print('---------') - print(name) - 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) - - - @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' - + def todo_view(my_todos): + the_view='List of ToDos:'+'
' + for todo in my_todos: + the_view+=(todo+'
') + the_view+='-----LIST ENDS HERE----' + return the_view + # return ( + # 'List of ToDos:'+'
'+ + # 'Wake Up' + '
' + + # 'Drink Coffee' + '
' + + # 'Read Non-fiction Novel' + '
'+ + # '-----LIST ENDS HERE----' + # ) + # a simple page that list my todos + @app.route('/saurabh') + def saurabh(): + todo=['wake Up','Lunch','Time Pass','Sleep'] + return todo_view(todo) + + @app.route('/shivang') + def shivang(): + todo=['Wake Up','Drink Coffee','Study','Sleep'] + return todo_view(todo) return app diff --git a/week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-37.pyc b/week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 00000000..69549095 Binary files /dev/null and b/week-0/day-3/my_todo_app/todo_app/__pycache__/__init__.cpython-37.pyc differ