Created
May 16, 2013 11:10
-
-
Save OrangeTux/5590994 to your computer and use it in GitHub Desktop.
Forget about the imports and accidental typo's.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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