Skip to content
Snippets Groups Projects
Commit 48a6bd0c authored by Steven Loria's avatar Steven Loria
Browse files

Add simple manage.py script

parent b7a79942
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ Features
- Flask-WTForms with login and registration forms
- Procfile for deploying to a PaaS (e.g. Heroku)
- nose for testing
- A simple ``manage.py`` script.
Screenshots
-----------
......
......@@ -13,4 +13,15 @@ Quickstart
git clone https://github.com/{{cookiecutter.github_username}}/{{ cookiecutter.repo_name }}
cd {{cookiecutter.repo_name}}
pip install -r requirements/dev.txt
python run.py
python manage.py createdb
python manage.py runserver
Shell
-----
To open the interactive shell, run ::
python manage.py shell
By default, you will have access to ``app``, ``models``, and ``db``.
#!/usr/bin/env python
from flask.ext.script import Manager, Shell, Server
from {{ cookiecutter.repo_name }} import models
from {{ cookiecutter.repo_name }}.main import app, db
manager = Manager(app)
def _make_context():
'''Return context dict for a shell session so you can access
app, db, and models by default.
'''
return {'app': app, 'db': db, 'models': models}
@manager.command
def createdb():
'''Create a database from the tables defined in models.py.'''
db.create_all()
manager.add_command("runserver", Server())
manager.add_command("shell", Shell(make_context=_make_context))
if __name__ == '__main__':
manager.run()
......@@ -3,3 +3,6 @@
# Testing
nose
# Management script
Flask-Script
# Everything that needed in production
Flask==0.10.1
Flask-SQLAlchemy==1.0
Flask-WTF==0.9.0
Flask-WTF==0.9.2
Jinja2==2.7
MarkupSafe==0.18
SQLAlchemy==0.8.2
WTForms==1.0.4
Werkzeug==0.9.3
Werkzeug==0.9.4
gunicorn==17.5
itsdangerous==0.23
wsgiref==0.1.2
......@@ -11,4 +11,4 @@ from .views import *
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
\ No newline at end of file
app.run(host='0.0.0.0', port=port)
......@@ -21,6 +21,6 @@ class User(db.Model):
self.password = password
def __repr__(self):
return '<User %r>' % (self.username)
return '<User "{username}">'.format(username=self.username)
db.create_all()
\ No newline at end of file
db.create_all()
# -*- coding: utf-8 -*-
import os
APP_DIR = os.path.abspath(os.path.dirname(__file__))
APP_DIR = os.path.abspath(os.path.dirname(__file__)) # This directory
PROJECT_ROOT = os.path.abspath(os.path.join(APP_DIR, os.pardir))
DB_NAME = "test.db"
DB_PATH = os.path.join(PROJECT_ROOT, DB_NAME)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment