Coder Social home page Coder Social logo

cookiecutter-flask / cookiecutter-flask Goto Github PK

View Code? Open in Web Editor NEW
4.5K 83.0 756.0 3.19 MB

A flask template with Bootstrap, asset bundling+minification with webpack, starter templates, and registration/authentication. For use with cookiecutter.

License: MIT License

Python 68.29% CSS 2.06% JavaScript 5.81% HTML 16.88% Dockerfile 4.43% Shell 2.36% Procfile 0.19%
cookiecutter flask python bootstrap webpack hacktoberfest cookiecutter-flask

cookiecutter-flask's Introduction

cookiecutter-flask

A Flask template for cookiecutter. (Supports Python ≥ 3.8)

Build Status CodeQL CalVer

See this repo for an example project generated from the most recent version of the template.

Use it now

Docker (This is the preferred method for creating a new project)

$ git clone https://github.com/cookiecutter-flask/cookiecutter-flask.git
$ cd cookiecutter-flask

# Basic usage (You will be prompted to provide basic information about your application)
$ ./cookiecutter-docker.sh
    full_name [Steven Loria]:
    ...
# The repository for your flask app will be created in a directory with the name
# chosen in "package import name" question (default ./my_flask_app/)

# Additional arguments are available
$ ./cookiecutter-docker.sh --help
    Usage: ./cookiecutter-docker.sh [OPTIONS]

Options:
    -b, --build    Build Docker image before running cookiecutter
    -h, --help     Show this message and exit

Standard

If using standard instructions, Python ≥ 3.8 is required. A virtual environment is recommended (like virtualenv).

pip3 install cookiecutter
cookiecutter https://github.com/cookiecutter-flask/cookiecutter-flask.git

You will be asked about your basic info (name, project name, app name, etc.). This info will be used in your new project.

Configure and Run

After you have generated the project code, a few more steps must be taken before your new app will run. The README of the generated project shows you how to configure and run the application. (You can see the template README here).

Features

  • Bootstrap 5 and Font Awesome 6 with starter templates
  • Flask-SQLAlchemy with basic User model
  • Easy database migrations with Flask-Migrate
  • Configuration in environment variables, as per The Twelve-Factor App
  • Flask-WTForms with login and registration forms
  • Flask-Login for authentication
  • Flask-Bcrypt for password hashing
  • Procfile for deploying to a PaaS (e.g. Heroku)
  • pytest and Factory-Boy for testing (example tests included)
  • Flask's Click CLI configured with simple commands
  • CSS and JS minification using webpack
  • npm support for frontend package management
  • Caching using Flask-Cache
  • Useful debug toolbar
  • Utilizes best practices: Blueprints and Application Factory patterns

Screenshots

Home page

Home page

Inspiration

License

MIT licensed.

Changelog

Unreleased

  • Update all node dependencies to latest versions
  • Switch to using Github Actions for template CI
  • Remove support for Node 10 as a Cookiecutter option
  • Refactored Docker image to use multistage builds more efficiently
  • Projects generated with the template use Github actions for CI
  • Upgrade Webpack to 5.x
  • Dropped Python 3.6, 3.7, and 3.8 support
  • Added Python 3.9, 3.10, 3.11, and 3.12 support
  • Added Node 18 and 20 LTS
  • Removed Node 12, 14, and 16 LTS

18.0.0 (09/09/2018)

  • Use CalVer (YY.MINOR.MICRO).
  • Upgrade to Bootstrap 4. Thanks @adawalli and @Hiyorim.
  • Use environment variables for configuration.
  • Add support for Pipenv.
  • Upgrade Python and Node dependencies.

0.13.0 (06/25/2017)

  • Use webpack for building front-end assets. Front-end dependencies are installed with NPM. Remove Flask-Assets and bower.json. Thanks @wroberts.

0.12.0 (11/06/2016)

  • Update Python dependencies.

0.11.1 (11/06/2016)

  • Correctly pass first parameter to Flask according to the 0.11 docs. Thanks @aliavni.
  • Remove setuptools and wheel as dependencies to fix deployment on Heroku. Thanks @Cabalist.
  • Make User.password a Binary field for compatibility with new versions of bcrypt. Thanks again @Cabalist.

0.11.0 (09/10/2016)

  • Use the FLASK_DEBUG system environment variable, instead of MYFLASKAPP_ENV, to control different configs for development and production environments

0.10.1 (08/28/2016)

  • Fix invoke test command.

0.10.0 (08/28/2016)

  • Update to Flask 0.11.
  • Use Click instead of Flask-Script for CLI commands.

0.9.0 (03/06/2016)

  • Update stale requirements.
  • Add CSRF protection.
  • Run lint command on Travis builds.
  • Test against Python 3.5.

0.8.0 (11/09/2015)

  • Update stale requirements.
  • Add lint, clean, and urls management commands.
  • Add isort.

Thanks @andreoliw for these contributions.

0.7.0 (04/14/2015)

  • Update extension import style to flask_* as per mitsuhiko/flask#1135.
  • Update stale requirements (Werkzeug, Flask-WTF, WTForms, Flask-Bcrypt, Flask-DebugToolbar, Flask-Migrate, Bootstrap, jQuery). Thanks @bsmithgall for notifying me of the critical patch to Flask-Migrate.

0.6.0 (12/01/2014)

  • Test the cookiecutter on Travis. Thanks @joshfriend.
  • Update stale requirements (Flask-WTF, Flask-Migrate, Flask-DebugToolbar)

0.5.0 (09/29/2014)

  • Fix .travis.yml.
  • Update stale requirements (Flask-WTF, WTForms, Flask-SQLAlchemy, jquery, Bootstrap)

0.4.3 (07/27/2014)

  • Add BaseFactory class.
  • Add compat.py module.
  • Tests pass on Python 3.

0.4.2 (07/27/2014)

  • Update factories to factory-boy >= 2.4.0 syntax.
  • Update stale requirements.

0.4.1 (06/07/2014)

  • Update stale requirements (Werkzeug 0.9.6, WTForms 2.0)
  • Fix unmatched div tag in home.html (thanks @level09)

0.4.0 (04/19/2014)

  • Add ReferenceCol for less verbose foreign key columns.
  • Add SurrogatePK mixin for adding integer primary key to a model.
  • Add base Model class that has CRUD convenience methods.
  • Fix setting BCrypt encryption complexity. Tests are much faster.
  • Add Role model to show ReferenceCol usage.
  • Switch to pytest.
  • Upgrade all out-of-date requirements.
  • More test examples.
  • Remove "year" from cookiecutter.json (just change LICENSE if necessary).

0.3.2 (02/26/2014)

  • Fix static assets.

0.3.1 (02/20/2014)

  • Update default year in cookiecutter.json. Thanks @Omeryl
  • Correct testing of redirects in webtests. Thanks @Widdershin
  • Fix POST action in nav form. Thanks @Widdershin.
  • Update Bootstrap (3.1.1) and jQuery (2.1.0)
  • Optional support for bower.
  • Minified assets aren't used in dev environment.

0.3.0 (12/08/2013)

  • More modular organization: each blueprint contains its own view, models, and forms in a directory. There is still a single directory for templates and static assets.
  • Use Flask-Bcrypt for password hashing.
  • Flask-Login for authentication.
  • Simple test setup. Just create a subclass of DbTestCase.
  • Flask-Testing support.
  • Use Factory-Boy for test factories.
  • Use WebTest for functional testing.
  • Add Flask-Debugtoolbar.
  • Migrations using Flask-Migrate.
  • Caching using Flask-Cache.
  • Add error page templates (404, 401, 500)
  • Add Font Awesome 4.0.3 for icons.

0.2.0 (09/21/2013)

  • Add manage.py script
  • Add Flask-Assets for CSS and JS bundling+minification
  • Use different configs for development and production environments, controlled by the MYFLASKAPP_ENV system environment variable
  • Use Blueprints and application factory pattern. The simple branch does not use these.

0.1.0 (08/20/2013)

  • First iteration
  • Bootstrap 3 final
  • Working User model and registration

cookiecutter-flask's People

Contributors

cabalist avatar caffeinatedmike avatar cbrown1234 avatar compscikai avatar dasdachs avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar derthorsten avatar hiyorimi avatar jamescurtin avatar jaza avatar jmcarp avatar kainbr avatar markman123 avatar matt-- avatar mbennett-uoe avatar nk9 avatar nstoik avatar nurfaizin avatar oerd avatar pyup-bot avatar sergioisidoro avatar sloria avatar tafkas avatar thuvh avatar tobked avatar torbjoernk avatar widdershin avatar ymek 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  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

cookiecutter-flask's Issues

Encode on check password

Hi man, on the check_password method of the User models I need to encode the password, otherwise I was receiving an error here:

Before:

def check_password(self, value):
        return bcrypt.check_password_hash(self.password, value)

After:

def check_password(self, value):
    return bcrypt.check_password_hash(self.password.encode('utf-8'), value)

That's just me?

Is there a step by step guide?

I was wondering if there is a step by step guide on how to get this template online. It seems that installing the requirements alone is not enough. I am a newbie and this is my first attempt to use cookiecutter.

virtualenv support thoughts

This is a nice repo. I did a flask template in my own git repo but this one is better and newer. The one thing I feel is missing is a script to start things up when interacting with your flask without affecting anything else that you have on your dev system and that is using a virtual environment. The script would setup the venv folder (which would have to be in .gitignore), install all the requirements, and then start the app.
Is this something that was considered in the past? If you think this would be useful then let me know and I'll PR for it with the proper cookiecutter settings.

Snippet

from __future__ import print_function
import os, sys
venv = 'venv/bin/activate_this.py'

def check_prg(name, install_info=None):
  if os.system("which {} > /dev/null".format(name)) != 0:
    print("ERROR: [{}] not found".format(name))
    if install_info is not None:
      print(install_info)
    sys.exit(1)

check_prg("pip", "Usual package: [python-pip]")
check_prg("virtualenv", "To install: [sudo pip install virtualenv]")

new_setup = False
if not os.path.exists(venv):
  new_setup = True
  print("{} does not exist. Creating it now...".format(venv))
  os.system("virtualenv venv")

try:
  execfile(venv, dict(__file__=venv))
except Exception as err:
  exit("Failed to start virtualenv: {}".format(err))

if new_setup:
  try:
    os.system("pip install -r requirements.txt")
  except Exception as err:
    exit("Failed to install requirements.txt")

from <<APP>> import app
print("\n\nServer is now running. Connect to port 5000")
my_app = app.create_app()
my_app.run(host='0.0.0.0', port=5000,  debug=True)

Running this:

cd /path/to//my_project
$ ./runserver.py                 
venv/bin/activate_this.py does not exist. Creating it now...
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home/nodarn/projects/miracles/venv/bin/python2
Also creating executable in /home/nodarn/projects/miracles/venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
....
Server is now running. Connect to port 5000
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat


Server is now running. Connect to port 5000
 * Debugger is active!
 * Debugger PIN: XXX-XXX-XXX

What are your thoughts?

MongoDefault

Any config options to make mongo or redis integrate nicely with this app structure?

FlaskMongo and Flask-MongoAlchemy examples provide app.py as the initialization and model containaining file. Still trying to sort through the app structure coming from a django background and light reading about flask.

Use envvars for configuration

According to twelve-factor, configuration should be specified in environment variables: https://12factor.net/config .

Local configuration can be specified in a gitignored .env file. I recommend that we add a .env.example file with defaults for a typical dev environment.

For reading and parsing envvars, there's environs .

New models don't get picked up by flask-migrate

I'm unable to add any new models to the migrations. Here's an example model I added for testing:

The folder structure is the same as the user module
{{cookiecutter.app_name}}/{{cookiecutter.app_name}}/example/
__init__.py
models.py

The example/models.py :

from flaskapp.database import Column, Model, SurrogatePK, db

class Example(SurrogatePK, Model):
    __tablename__ =  'examples'

I also added an import to app.py for whatever it's worth
from flaskapp import commands, public, user, scraper, example

I run flask db init and then flask db migrate but it only ever detects the users and roles models.

I've tried a variety of techniques to get new models defined, but only new models defined in user/models.py ever get detected when I run a migration.

Any help would be greatly appreciated. Thanks!

NoAppException: The file/path provided (autoapp) does not appear to exist.

I've followed the README for this project but flask.cli keeps throwing me this exception when I try to run flask.

NoAppException: The file/path provided (autoapp) does not appear to exist.  Please 
verify the path is correct.  If app is not on PYTHONPATH, ensure the extension is .py

StackOverflow seems to think it's an issue with exporting FLASK_APP=autoapp.py vs FLASK_APP=autoapp. I've tried them both in addition to using the absolute path for the above two variations.

Any thoughts how I can fix this?

Need to add extra commands to retrieve and install twill

Guess this isn't your problem but should probably be in the readme somewhere.

pip install -r requirements/dev.txt gives the following error:

Downloading/unpacking twill (from Flask-Testing->-r dev.txt (line 6))
  Could not find any downloads that satisfy the requirement twill (from Flask-Testing->-r dev.txt (line 6))
  Some externally hosted files were ignored (use --allow-external twill to allow).
  Some insecure and unverifiable files were ignored (use --allow-unverified twill to allow).

The following command works fine:
pip install -r requirements/dev.txt --allow-external twill --allow-unverified twill

I'm using Arch Linux x64 in VB.

Run tests in parallel using pytest-xdist

Is it possible to modify the fixtures so that the tests can be run in parallel using pytest-xdist plugin. Currently the way session (and db) is created, they don't play well with running the tests in parallel.

Fix template context to have current_user

When implementing cookiecutter-flask, it will not display pages because app/app/templates/nav.html is looking for current_user, but it is not placed into the template context.

My workaround is to add the following to app/app/user/views.py:

from  flask.ext.login import current_user

@blueprint.app_context_processor
def userinfo():
    return dict(current_user=current_user)

No CSS,JS created

When the templated is rendered the first time, no CSS or JS files are created inside - public/css/common.css and public/js/common.js

Firebug shows that the they are served from /static/js and /static/css instead. How to make sure that the changed JS gets reflected in the app ?

Deploying to Heroku fails to fetch static assets

I created an instance of this cookiecutter and put it here. When I push to Heroku, the app launches but throws this exception when I try to use the app in a browser:

  File "/app/members/app.py", line 51, in render_error 
    return render_template('{0}.html'.format(error_code)), error_code 
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/templating.py", line 128, in render_template 
    context, ctx.app) 
  File "/app/.heroku/python/lib/python2.7/site-packages/flask/templating.py", line 110, in _render 
    rv = template.render(context) 
  File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render 
    return self.environment.handle_exception(exc_info, True) 
  File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception 
    reraise(exc_type, exc_value, tb) 
  File "/app/members/templates/500.html", line 2, in top-level template code 
    {% extends "layout.html" %} 
  File "/app/members/templates/layout.html", line 24, in top-level template code 
    {% assets "css_all" %} 
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/ext/jinja2.py", line 186, in _render_assets 
    urls = bundle.urls() 
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/bundle.py", line 787, in urls 
    urls.extend(bundle._urls(new_ctx, extra_filters, *args, **kwargs)) 
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/bundle.py", line 746, in _urls 
    *args, **kwargs) 
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/bundle.py", line 600, in _build 
    force, disable_cache=disable_cache, extra_filters=extra_filters) 
  File "/app/.heroku/python/lib/python2.7/site-packages/webassets/bundle.py", line 546, in _merge_and_apply 
    raise BuildError(e) 
BuildError: [Errno 2] No such file or directory: '/app/members/static/libs/bootstrap/dist/css/bootstrap.css'

What steps did I miss?

Bootstrap glyphicon font unavailable from minified CSS

This is not an issue when running against the DevConfig, since the CSS is not minified in that case.

When the Bootstrap CSS is minified and bundled with other CSS, it is effectively 'moved' to another location relative to the bootstrap fonts.

I'm not sure what a good solution for this problem is.

CSRF on login

When trying to login with the header form, I receive an error that the CSRF was not been sent, needed to change in the nav.html

{{ form.hidden_tag() }}

To this:

<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>

And put on the app.py:

flask_wtf.CsrfProtect(app)

Like is been said here

Paths to static files

assets.py, and the README.md in static/libs/boostrap shows a directory structure with 'bootsrap/css/bootstrap.css'. But the 'dist' folder is missing?

If it's not intended I guess I can make a quick pull request

Switching mysql for postgresql

How would one change out the database engine used from postgresql to mysql for prod? Basically to what extent is postgre tied into the application so one would know what all needs to be updated to support alternative engines.

Git origin - upstream

Hi, usually I work with origin and upstream from Git. How does this fit with cookiecutter. How can I benefit from updates on cookiecutter-flask without using origin and upstream functionality. Thanks.

python3.6 many import errors

I checked out and setup the project following the instructions in the readme.rst. Unfortunately I get an import error in flask.cli https://github.com/pallets/flask/blob/0.12-maintenance/flask/cli.py#L90 when it tries to import the autoapp.py module. The import error happens here https://github.com/sloria/cookiecutter-flask/blob/master/%7B%7Bcookiecutter.app_name%7D%7D/autoapp.py#L5 . I think this is happening because there are 2 {{cookiecutter.app_name}} directories.
So I tried changing the autoapp.py imports to

from .{{cookiecutter.app_name}} import create_app
from .{{cookiecutter.app_name}} import DevConfig, ProdConfig

That fixed the import errors in that file but I started getting import errors in a bunch of other files. I tried fixing them one at a time but unfortunately __import__ doesn't provide any context when it fails to import a module. So I'm having trouble tracking down all the bad imports.

Also I tested this project in python2.7 and had no issues whatsoever with imports.

I have feeling these import errors are present in any version of python3. I will try to find a tool to automatically convert the python2 imports to python3. If I'm successful I''l make a PR bugfix

EDIT
I managed to get it to work in python3.5/3.6. I deleted the cookiecutter and recloned, I think my issue might have been because my app_name was the same as my project_name.

2nd EDIT
I've checked out the cookiecutter and gone through the install process a few times now, but I'm unable to reproduce my original import errors.

Exception during login

With latest PR #80 I can register new users, but I get an error "TypeError: string argument without an encoding" (trace see below) when logging in.

  • Python 3.4.3
  • PostgreSQL 9.5.4
  • SQLAlchemy 1.0.12
  • Flask-SQLAlchemy 2.1

Error does not occur when I use SQLite as database.

(Note: I get login to work by reverting #80 by changing password = Column(db.Binary(128), nullable=True) back to change password = Column(db.String(128), nullable=True) in conjunction with updated set_password() implementation as suggested by @Smewp in a comment to #80. But as @Cabalist pointed out in the same thread, this is rather a workaround than a solution.)

Traceback (most recent call last):
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask_debugtoolbar/__init__.py", line 125, in dispatch_request
    return view_func(**req.view_args)
  File "/simrech/backend2/simrech/public/views.py", line 26, in home
    if form.validate_on_submit():
  File "/simrech/backend2/venv/lib/python3.4/site-packages/flask_wtf/form.py", line 166, in validate_on_submit
    return self.is_submitted() and self.validate()
  File "/simrech/backend2/simrech/public/forms.py", line 27, in validate
    self.user = User.query.filter_by(username=self.username.data).first()
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2634, in first
    ret = list(self[0:1])
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2457, in __getitem__
    return list(res)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/orm/loading.py", line 86, in instances
    util.raise_from_cause(err)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/util/compat.py", line 184, in reraise
    raise value
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/orm/loading.py", line 71, in instances
    rows = [proc(row) for row in fetch]
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/orm/loading.py", line 71, in <listcomp>
    rows = [proc(row) for row in fetch]
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/orm/loading.py", line 428, in _instance
    loaded_instance, populate_existing, populators)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/orm/loading.py", line 486, in _populate_full
    dict_[key] = getter(row)
  File "/simrech/backend2/venv/lib/python3.4/site-packages/sqlalchemy/sql/sqltypes.py", line 859, in process
    value = bytes(value)
TypeError: string argument without an encoding

KeyError when installing.

Here's what I'm getting. I'm on Mac OSX.

$ cookiecutter https://github.com/sloria/cookiecutter-flask.git
Cloning into 'cookiecutter-flask'...
remote: Reusing existing pack: 581, done.
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 590 (delta 0), reused 3 (delta 0)
Receiving objects: 100% (590/590), 597.03 KiB | 43.00 KiB/s, done.
Resolving deltas: 100% (312/312), done.
Checking connectivity... done
full_name (default is "Steven Loria")? 
email (default is "[email protected]")? 
github_username (default is "sloria")? 
project_name (default is "My Flask App")? 
app_name (default is "myflaskapp")? 
project_short_description (default is "A flasky app.")? 
year (default is "2013")? 
Traceback (most recent call last):
  File "/usr/local/bin/cookiecutter", line 8, in <module>
    load_entry_point('cookiecutter==0.6.4', 'console_scripts', 'cookiecutter')()
  File "/Library/Python/2.7/site-packages/cookiecutter/main.py", line 90, in main
    cookiecutter(args.input_dir)
  File "/Library/Python/2.7/site-packages/cookiecutter/main.py", line 67, in cookiecutter
    generated_project = context['cookiecutter']['repo_name']
KeyError: 'repo_name'

Upgrade to Flask 0.11

Part of this could be to replace the dependency on Flask-Script with the new Flask CLI.

Build fails on Travis CI

When a build of the project generated by cookiecutter-flask is run on Travis CI, build fails with this error:

ImportError: No module named flask.ext.debugtoolbar

I think the reason why build fails is that dependency on Flask-DebugToolbar is defined only on {{cookiecutter.app_name}}/requirements/dev.txt. As shown in {{cookiecutter.app_name}}/.travis.yml, only dependencies for production environment are resolved, which prevents Flask-DebugToolbar from being installed on the build environment. However, in {{cookiecutter.app_name}}/{{cookiecutter.app_name}}/extensions.py, the extension is referred regardless of app configuration. This means that the Flask app tries to use Flask-DebugToolbar extension even in configuration for tests and production.

This part should be modified to make the app not use the extension if the app is not in development environment.

Can't running IDE debugger. Database connection issue when modifying autoapp.py

This is more of a question rather than an issue. I would like to use the PyCharm debugger, but in order to do this, I should run autoapp.py through the IDE interface, not call flask run from the command line. However, upon adding the line app.run() to autoapp.py, when attempting to login, I receive the following error.

OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?

This seems to be common (not just to this project). Do I need to adjust my database in order to run the application directly from autoapp.py?

Thanks!

Password saving fails due to Binary column type

Maybe some compatibility stuff is needed here, because this commit 570d5bc made impossible to save a password on PostgreSQL 9.5 (Python 3.6). Getting TypeError: can't escape str to binary.
Or at least a comment there to lower the debugging time. What do you think?

Error on custom errorhandler

When debugging, "error" doesn't have "code" attribute.

> /Users/ayik/dev/tinular/puspa/puspa/app.py(52)render_error()
     51         import ipdb; ipdb.set_trace()
---> 52         return render_template("{0}.html".format(error.code)), error.code
     53     for errcode in [401, 404, 500]:
ipdb> error
ProgrammingError('(ProgrammingError) relation "users" does not exist\nLINE 2: FROM users \n             ^\n',)
ipdb> 
127.0.0.1 - - [07/May/2014 18:21:50] "POST / HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File "/Users/ayik/.virtualenvs/puspa/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
    execute(self.server.app)
  File "/Users/ayik/.virtualenvs/puspa/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
    application_iter = app(environ, start_response)
  File "/Users/ayik/.virtualenvs/puspa/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/ayik/.virtualenvs/puspa/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/Users/ayik/.virtualenvs/puspa/lib/python2.7/site-packages/flask/app.py", line 1410, in handle_exception
    return handler(e)
  File "/Users/ayik/dev/tinular/puspa/puspa/app.py", line 51, in render_error
    return render_template("{0}.html".format(error.code)), error.code
AttributeError: 'ProgrammingError' object has no attribute 'code'

ValueError: path is on drive e:, start on drive C:

This occurred on Windows when I visit http://127.0.0.1:5000/

flask_debugtoolbar\panels\versions.py", line 51, in content

line 12
relative = os.path.relpath(location, python_lib)

and
location is C:\\Python27\\Lib\\site-packages
python_lib is e:\\work\\py\\flask-restaction

os.relpath does give you a relative path between two directories.

The problem you are encountering is that, on Windows, a relative path
doesn't even exist if the two directories are on different drives

Generated .gitignore clobbers alembic's evn.py

I pulled down my teammate's app and was getting a lot of fun Can't find Python file migrations/env.py but trying to re-db init was complaining that init had already been run. Looks like the env* wildcard in .gitignore didn't let her check in the env.py file alembic generates.

ImportError: No module named flask.ext.debugtoolbar

When running with prod requirements startup chokes at the import statement in extensions.py:21. I think there's 2 possible solutions:

  1. Move the debug toolbar to prod requirements (prod.txt).
  2. Try to check the debug flag to avoid hard errors. I think this would require some import gymnastics to wait until the config is present before importing the toolbar.

Thoughts?

Customize path to .cookiecutterrc

Any chance cookiecutter could allow us to read from a cookiecutterrc file stored in another location (i.e. the XDG default: ~/.config/cookiecutter/config). I really like having my home uncluttered - and lately have been trying to move my configuration files out as much as possible.

This could be done several simple ways:

  1. Make cookiecutter check (by default) the current location & for an XDG compatible configuration file.
  2. Add a config flag (cookiecutter <...> --config=~/.config/cookiecutter/config)
  3. Read an environment variable, if it exists:
import os
config_file = os.getenv('COOKIECUTTER_CONFIG', '~/.cookiecutterrc`)

Docker Support

I have a working docker configuration lying around using docker-compose for dev/prod. If there's any interest in that, I'd wrap it up and submit a pull request.

current_user not usable in blueprints

I'm probably just being thick, but I've been trying to build user profile update forms and am unable to the do the usual current_user object stuff I've used in the past.

Is there something about factories and blueprints I'm missing? The current_user proxy is definitely there in the templates, I just can't use it anywhere else. For instance
in user/views.py
from flask.ext.login import (current_user, login_required)

...
form.populate_obj(current_user)

results in the login manager nulling the current_user object. I can access properties (user_id, for instance).

Problem with registering error_handlers

Hey,

I am currently working on my own cookiecutter and use your version as a foundation. While doing so I came across a possible error inside your app.py (I might be wrong here, though).
Your app tries to register the error handlers with:

app.errorhandler(errcode)(render_error)

This did not work for me, though. I looked at the man pages and changed the code to the following:

app.register_error_handler(errcode, render_error)

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.