<s> from time import sleep <EOL> from cosmic . api import API <EOL> from cosmic . http import Server <EOL> from cosmic . types import * <EOL> from cosmic . models import BaseModel <EOL> from cosmic . exceptions import NotFound <EOL> words = API ( '<STR_LIT>' ) <EOL> @ words . action ( accepts = String , returns = String ) <EOL> def pluralize ( word ) : <EOL> if word . endswith ( '<STR_LIT:y>' ) : <EOL> return word [ : - <NUM_LIT:1> ] + '<STR_LIT>' <EOL> else : <EOL> return word + '<STR_LIT:s>' <EOL> @ words . model <EOL> class Word ( BaseModel ) : <EOL> methods = [ '<STR_LIT>' ] <EOL> properties = [ <EOL> required ( u"<STR_LIT>" , String ) <EOL> ] <EOL> @ classmethod <EOL> def get_by_id ( cls , id ) : <EOL> if id == "<STR_LIT:0>" : <EOL> return { "<STR_LIT>" : "<STR_LIT:hello>" } <EOL> else : <EOL> raise NotFound <EOL> @ words . action ( accepts = Integer ) <EOL> def lock_thread ( seconds ) : <EOL> sleep ( seconds ) <EOL> @ words . action ( accepts = Representation ( Model ( '<STR_LIT>' ) ) , returns = Integer ) <EOL> def count_letters ( word ) : <EOL> return len ( word [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) <EOL> wsgi_app = Server ( words ) . wsgi_app <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> words . run ( use_reloader = True ) </s>
