Code Monkey home page Code Monkey logo

flasky-first-edition's Introduction

Flasky

This repository contains the archived source code examples for my O'Reilly book Flask Web Development, first edition. For the code examples for the current edition of the book, go to https://github.com/miguelgrinberg/flasky.

The commits and tags in this repository were carefully created to match the sequence in which concepts are presented in the book. Please read the section titled "How to Work with the Example Code" in the book's preface for instructions.

flasky-first-edition's People

Contributors

miguelgrinberg 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flasky-first-edition's Issues

`flask_script` deprecated

Hello, I know this repo is deprecated but just want to point out that it seems that flask_script is no longer maintained and there is a bug when importing, it will import flask._compact instead of flask_script._compact.

Send html unicode utf-8 with flask_mail

Is there a parameter to be passed for flask_mail to accept unicode utf-8?

I'm trying to pass character like: "Ç é Ã ã à"

but flask_mail does not send these characters correctly

Heroku Error on creating relations on deploy command

Hi, I'm finishing the Flasky first edition book - I think it's excellent!
I'm having a problem in the last bit though - deploying to Heroku.
The app is working fine in the local environment. I've also triple checked all my code to the github for Flaksy 1 and also had a look at the github for Flasky 2 edition and the Flask Mega Tutorial for clues as to where I'm going wrong and can't see any.

The code is uploaded to Heroku fine, all the packages from requirements are loaded, and the application starts.
But then I try to run the deploy code
heroku python manage.py deploy

I get the error message:
"psycopg2.errors.UndefinedTable: relation "roles" does not exist"

So, have I set up my database incorrectly? I've looked at models.py very closely compared with yours and can't see any difference, especially w.r.t. Roles and Users. The database is also working fine under a local server.

Full traceback is pasted below. Any tips or hints, or how I can start the database afresh?
Thanks, Doug.

INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> e16ed9da28b5, Add index to Role
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1178, in _execute_context
self.dialect.do_execute(
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.UndefinedTable: relation "roles" does not exist

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/app/manage.py", line 82, in
manager.run()
File "/app/.heroku/python/lib/python3.9/site-packages/flask_script/init.py", line 417, in run
result = self.handle(argv[0], argv[1:])
File "/app/.heroku/python/lib/python3.9/site-packages/flask_script/init.py", line 386, in handle
res = handle(*args, **config)
File "/app/.heroku/python/lib/python3.9/site-packages/flask_script/commands.py", line 216, in call
return self.run(*args, **kwargs)
File "/app/manage.py", line 72, in deploy
upgrade()
File "/app/.heroku/python/lib/python3.9/site-packages/flask_migrate/init.py", line 247, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/script/base.py", line 425, in run_env
util.load_python_file(self.dir, 'env.py')
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/util/pyfiles.py", line 93, in load_python_file
module = load_module_py(module_id, path)
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/util/compat.py", line 63, in load_module_py
return machinery.SourceFileLoader(
File "", line 529, in _check_name_wrapper
File "", line 1034, in load_module
File "", line 859, in load_module
File "", line 274, in _load_module_shim
File "", line 711, in _load
File "", line 680, in _load_unlocked
File "", line 855, in exec_module
File "", line 228, in _call_with_frames_removed
File "migrations/env.py", line 90, in
run_migrations_online()
File "migrations/env.py", line 84, in run_migrations_online
context.run_migrations()
File "", line 8, in run_migrations
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/runtime/environment.py", line 836, in run_migrations
self.get_context().run_migrations(**kw)
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/runtime/migration.py", line 330, in run_migrations
step.migration_fn(**kw)
File "/app/migrations/versions/e16ed9da28b5_add_index_to_role.py", line 21, in upgrade
op.create_index(op.f('ix_roles_name'), 'roles', ['name'], unique=True)
File "", line 8, in create_index
File "", line 3, in create_index
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/operations/ops.py", line 857, in create_index
return operations.invoke(op)
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/operations/base.py", line 318, in invoke
return fn(self, operation)
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/operations/toimpl.py", line 88, in create_index
operations.impl.create_index(idx)
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/ddl/impl.py", line 206, in create_index
self._exec(schema.CreateIndex(index))
File "/app/.heroku/python/lib/python3.9/site-packages/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 945, in execute
return meth(self, multiparams, params)
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 997, in _execute_ddl
ret = self._execute_context(
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1184, in _execute_context
self._handle_dbapi_exception(
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1400, in _handle_dbapi_exception
util.raise_from_cause(
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
raise value.with_traceback(tb)
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1178, in _execute_context
self.dialect.do_execute(
File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "roles" does not exist
[SQL: 'CREATE UNIQUE INDEX ix_roles_name ON roles (name)']

Flask bad request response 400

In chapter 11a I find the following bad request 400 error, it seems that it is a flask error when sending a form or an invalid request I have tried to correct the error but still I cannot download the original source code and start the server and there is no way, the error persists

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.