Giter Site home page Giter Site logo

rtzll / flask-todolist Goto Github PK

View Code? Open in Web Editor NEW
141.0 141.0 109.0 492 KB

exemplary flask application - small to-do list WebApp example

Home Page: https://rtzll.github.io/flask-todolist

License: MIT License

Python 79.27% JavaScript 3.86% HTML 10.40% CSS 5.86% Mako 0.45% Dockerfile 0.15%
flask python todolist webapp

flask-todolist's Introduction

๐Ÿ‘‹

flask-todolist's People

Contributors

decroc-shell avatar dependabot[bot] avatar rtzll avatar skylor-tang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask-todolist's Issues

Only the first todo in the todolist view can be closed/reopend.

That is, the first in the list of open or finished todos.
This is most likely because of the jQuery selection in site.js:

$(':checkbox').on('click', changeTodoStatus);

  function changeTodoStatus() {
    if($('#checkbox').is(':checked')) {
      finishTodo(this);
    } else {
      reopenTodo(this);
    }
  }

Internal Service Error

It looks like the tables are not created with docker-compose quickstart.

todolist     | [2020-02-01 18:59:33 +0000] [8] [ERROR] Error handling request /todolist/new/
todolist     | Traceback (most recent call last):
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1246, in _execute_context
todolist     |     cursor, statement, parameters, context
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
todolist     |     cursor.execute(statement, parameters)
todolist     | sqlite3.OperationalError: no such table: todolist
todolist     | 
todolist     | The above exception was the direct cause of the following exception:
todolist     | 
todolist     | Traceback (most recent call last):
todolist     |   File "/usr/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle
todolist     |     self.handle_request(listener, req, client, addr)
todolist     |   File "/usr/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
todolist     |     respiter = self.wsgi(environ, resp.start_response)
todolist     |   File "/usr/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
todolist     |     return self.wsgi_app(environ, start_response)
todolist     |   File "/usr/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
todolist     |     response = self.handle_exception(e)
todolist     |   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
todolist     |     reraise(exc_type, exc_value, tb)
todolist     |   File "/usr/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
todolist     |     raise value
todolist     |   File "/usr/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
todolist     |     response = self.full_dispatch_request()
todolist     |   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
todolist     |     rv = self.handle_user_exception(e)
todolist     |   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
todolist     |     reraise(exc_type, exc_value, tb)
todolist     |   File "/usr/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
todolist     |     raise value
todolist     |   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
todolist     |     rv = self.dispatch_request()
todolist     |   File "/usr/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
todolist     |     return self.view_functions[rule.endpoint](**req.view_args)
todolist     |   File "/code/app/main/views.py", line 46, in new_todolist
todolist     |     todolist = TodoList(creator=_get_user()).save()
todolist     |   File "/code/app/models.py", line 45, in save
todolist     |     self.__commit()
todolist     |   File "/code/app/models.py", line 33, in __commit
todolist     |     db.session.commit()
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/scoping.py", line 162, in do
todolist     |     return getattr(self.registry(), name)(*args, **kwargs)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1036, in commit
todolist     |     self.transaction.commit()
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 503, in commit
todolist     |     self._prepare_impl()
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 482, in _prepare_impl
todolist     |     self.session.flush()
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2479, in flush
todolist     |     self._flush(objects)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2617, in _flush
todolist     |     transaction.rollback(_capture_exception=True)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
todolist     |     compat.reraise(exc_type, exc_value, exc_tb)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
todolist     |     raise value
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2577, in _flush
todolist     |     flush_context.execute()
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
todolist     |     rec.execute(self)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
todolist     |     uow,
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
todolist     |     insert,
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1137, in _emit_insert_statements
todolist     |     statement, params
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 982, in execute
todolist     |     return meth(self, multiparams, params)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 293, in _execute_on_connection
todolist     |     return connection._execute_clauseelement(self, multiparams, params)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1101, in _execute_clauseelement
todolist     |     distilled_params,
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1250, in _execute_context
todolist     |     e, statement, parameters, cursor, context
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception
todolist     |     util.raise_from_cause(sqlalchemy_exception, exc_info)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
todolist     |     reraise(type(exception), exception, tb=exc_tb, cause=cause)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise
todolist     |     raise value.with_traceback(tb)
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1246, in _execute_context
todolist     |     cursor, statement, parameters, context
todolist     |   File "/usr/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
todolist     |     cursor.execute(statement, parameters)
todolist     | sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: todolist
todolist     | [SQL: INSERT INTO todolist (title, created_at, creator) VALUES (?, ?, ?)]
todolist     | [parameters: ('untitled', '2020-02-01 18:59:33.031390', None)]
todolist     | (Background on this error at: http://sqlalche.me/e/e3q8)

Registration error

Hi there,

I run the up with docker compose and when I submitted my registration I got the following error:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user [SQL: 'SELECT user.username AS user_username, user.email AS user_email, user.id AS user_id, user.password_hash AS user_password_hash, user.member_since AS user_member_since, user.last_seen AS user_last_seen, user.is_admin AS user_is_admin \nFROM user \nWHERE user.email = ?\n LIMIT ? OFFSET ?'] [parameters: ('[email protected]', 1, 0)] (Background on this error at: http://sqlalche.me/e/e3q8)

It seems that the table does not exist. Aren't the tables created automatically at runtime ?

Docker-Compose Build Issue

I'm getting the below error while running the docker-compose build.

Using legacy 'setup.py install' for greenlet, since package 'wheel' is not installed.
Installing collected packages: MarkupSafe, Werkzeug, six, Jinja2, itsdangerous, greenlet, click, SQLAlchemy, python-editor, python-dateutil, Mako, Flask, WTForms, idna, Flask-SQLAlchemy, dnspython, alembic, Flask-WTF, Flask-Migrate, Flask-Login, email-validator
Running setup.py install for MarkupSafe: started
Running setup.py install for MarkupSafe: finished with status 'done'
Running setup.py install for greenlet: started
Running setup.py install for greenlet: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c0kweeja/greenlet_7b8393c261324bdaa6c1a0ad36d8c107/setup.py'"'"'; file='"'"'/tmp/pip-install-c0kweeja/greenlet_7b8393c261324bdaa6c1a0ad36d8c107/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-5jft_56b/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/greenlet
cwd: /tmp/pip-install-c0kweeja/greenlet_7b8393c261324bdaa6c1a0ad36d8c107/
Complete output (77 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/greenlet
copying src/greenlet/init.py -> build/lib.linux-x86_64-3.8/greenlet
creating build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_contextvars.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_cpp.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_version.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_stack_saved.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_generator.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_gc.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_extension_interface.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_leaks.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_weakref.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_generator_nested.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_tracing.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_throw.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/init.py -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/test_greenlet.py -> build/lib.linux-x86_64-3.8/greenlet/tests
running egg_info
writing src/greenlet.egg-info/PKG-INFO
writing dependency_links to src/greenlet.egg-info/dependency_links.txt
writing requirements to src/greenlet.egg-info/requires.txt
writing top-level names to src/greenlet.egg-info/top_level.txt
adding license file 'LICENSE' (matched pattern 'LICEN[CS]E*')
adding license file 'LICENSE.PSF' (matched pattern 'LICEN[CS]E*')
adding license file 'AUTHORS' (matched pattern 'AUTHORS*')
reading manifest file 'src/greenlet.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
warning: no files found matching '.py' under directory 'appveyor'
warning: no previously-included files matching '
.pyc' found anywhere in distribution
warning: no previously-included files matching '.pyd' found anywhere in distribution
warning: no previously-included files matching '
.so' found anywhere in distribution
warning: no previously-included files matching '.coverage' found anywhere in distribution
writing manifest file 'src/greenlet.egg-info/SOURCES.txt'
copying src/greenlet/greenlet.c -> build/lib.linux-x86_64-3.8/greenlet
copying src/greenlet/greenlet.h -> build/lib.linux-x86_64-3.8/greenlet
copying src/greenlet/slp_platformselect.h -> build/lib.linux-x86_64-3.8/greenlet
creating build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/setup_switch_x64_masm.cmd -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_aarch64_gcc.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_alpha_unix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_amd64_unix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_arm32_gcc.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_arm32_ios.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_csky_gcc.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_m68k_gcc.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_mips_unix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_ppc64_aix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_ppc64_linux.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_ppc_aix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_ppc_linux.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_ppc_macosx.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_ppc_unix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_riscv_unix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_s390_unix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_sparc_sun_gcc.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_x32_unix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_x64_masm.asm -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_x64_masm.obj -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_x64_msvc.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_x86_msvc.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/platform/switch_x86_unix.h -> build/lib.linux-x86_64-3.8/greenlet/platform
copying src/greenlet/tests/_test_extension.c -> build/lib.linux-x86_64-3.8/greenlet/tests
copying src/greenlet/tests/_test_extension_cpp.cpp -> build/lib.linux-x86_64-3.8/greenlet/tests
running build_ext
building 'greenlet._greenlet' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
creating build/temp.linux-x86_64-3.8/src/greenlet
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fomit-frame-pointer -g -fno-semantic-interposition -fomit-frame-pointer -g -fno-semantic-interposition -fomit-frame-pointer -g -fno-semantic-interposition -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python3.8 -c src/greenlet/greenlet.c -o build/temp.linux-x86_64-3.8/src/greenlet/greenlet.o
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c0kweeja/greenlet_7b8393c261324bdaa6c1a0ad36d8c107/setup.py'"'"'; file='"'"'/tmp/pip-install-c0kweeja/greenlet_7b8393c261324bdaa6c1a0ad36d8c107/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-5jft_56b/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/greenlet Check the logs for full command output.
ERROR: Service 'migration' failed to build : The command '/bin/sh -c python3 -m pip install -r requirements.txt' returned a non-zero code: 1

Error whilst trying to run docker compose up

When I try to do the following commands I get an error. I am trying to run a docker-compose to run the flask-todolist. I have Windows 10 version : 10.0.19043 N/A Build 19043 and docker version 20.10.16, build aa7e414. I am unable to run docker-compose up

commands on cmd

docker-compose build
docker-compose up

Error:

C:\Users\Edge\Desktop\todolist\flask-todolist>docker-compose up
[+] Running 1/0
 - Container todolist  Created                                                                                     0.0s
Attaching to todolist
todolist  |  * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
todolist  | Usage: flask db upgrade [OPTIONS] [REVISION]
todolist  | Try 'flask db upgrade --help' for help.
todolist  |
todolist  | Error: While importing 'todolist', an ImportError was raised:
todolist  |
todolist  | Traceback (most recent call last):
todolist  |   File "/usr/local/lib/python3.10/site-packages/flask/cli.py", line 256, in locate_app
todolist  |     __import__(module_name)
todolist  |   File "/code/todolist.py", line 1, in <module>
todolist  |     from app import create_app
todolist  |   File "/code/app/__init__.py", line 2, in <module>
todolist  |     from flask_login import LoginManager
todolist  |   File "/usr/local/lib/python3.10/site-packages/flask_login/__init__.py", line 16, in <module>
todolist  |     from .login_manager import LoginManager
todolist  |   File "/usr/local/lib/python3.10/site-packages/flask_login/login_manager.py", line 24, in <module>
todolist  |     from .utils import (login_url as make_login_url, _create_identifier,
todolist  |   File "/usr/local/lib/python3.10/site-packages/flask_login/utils.py", line 13, in <module>
todolist  |     from werkzeug.security import safe_str_cmp
todolist  | ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security' (/usr/local/lib/python3.10/site-packages/werkzeug/security.py)
todolist  |
todolist exited with code 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.