Skip to content

Instantly share code, notes, and snippets.

@OrangeTux
Created May 16, 2013 11:10
Show Gist options
  • Save OrangeTux/5590994 to your computer and use it in GitHub Desktop.
Save OrangeTux/5590994 to your computer and use it in GitHub Desktop.
Forget about the imports and accidental typo's.
### app.py ###
app = Flask(__name__)
app.register_blueprint(keywords.blueprint)
manager = CouchDBManager()
manager.setup(app)
manager.add_document(Keyword)
server = Server()
manager.sync(app)
if __name__ == '__main__':
app.run()
### blueprints/keywords.py ###
blueprint = Blueprint('keywords', __name__)
@blueprint.route('/keywords)
def handle_keywords():
for keyword in Keyword.search['name']:
print keyword
### models/keyword.py ###
class Keyword(Document):
doc_type = 'keyword'
content=TextField()
search = ViewField(
'docs', "function(doc) {\
if(doc.doc_type == 'keyword') {\
if(doc.content == content) {\
emit(doc.id, doc);
}\
}\
}"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment