Created
June 17, 2012 12:04
-
-
Save damilare/2944350 to your computer and use it in GitHub Desktop.
Case correction service
This file contains 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
import re, web, urlparse | |
def correct_case(text): | |
return ' '.join(['%s.' % x.strip().capitalize() for x in re.split('\.', text) if x]) | |
urls = ( | |
'/api/correct_case','CaseService' | |
) | |
app = web.application(urls, globals()) | |
class CaseService: | |
def GET(self): | |
return 'Please send a POST request' | |
def POST(self): | |
text = None | |
data = urlparse.parse_qsl(web.data()) | |
for k,v in data: | |
if k == 'str': | |
text = v | |
if text: | |
return correct_case(text) | |
else: | |
return 'Please send you text in a str parameter' | |
if __name__ == "__main__": | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment