Skip to content

Commit

Permalink
Base Code
Browse files Browse the repository at this point in the history
  • Loading branch information
tapaswenipathak committed Sep 3, 2014
1 parent 1a48097 commit 203be8f
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: newrelic-admin run-program gunicorn -b 0.0.0.0:$PORT server:app
10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Flask==0.10.1
Jinja2==2.7.3
MarkupSafe==0.23
Werkzeug==0.9.6
beautifulsoup4==4.3.2
gunicorn==19.0.0
itsdangerous==0.24
newrelic==2.22.1.20
horoscope==0.1.1
wsgiref==0.1.2
129 changes: 129 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
from flask import Flask, jsonify
from horoscope import Horoscope

app = Flask (__name__)

############################################
# Index
############################################

@app.route ('/', methods=['GET'])
def index_route () :
return jsonify({
'author' : 'Tapasweni Pathak',
'author_url' : 'http://tapasweni-pathak.github.io/',
'base_url' : 'horoscope-api.herokuapp.com',
'project_name' : 'Horoscope API',
'project_url' : 'http://tapasweni-pathak.github.io/pyhoroscope/'
})


############################################
# Horoscopes
###########################################

#Todays' Horoscope
@app.route ('/horoscope/today/<sunsign>', methods=['GET'])
def today_horoscope_route (sunsign) :
result = dict (Horoscope.get_todays_horoscope (sunsign))
return jsonify (date=result['date'],
sunsign=result['sunsign'],
horoscope=result['horoscope'])


#Current Week Horoscope
@app.route ('/horoscope/week/<sunsign>', methods=['GET'])
def weekly_horoscope_route (sunsign) :
result = dict (Horoscope.get_weekly_horoscope (sunsign))
return jsonify (week=result['week'],
sunsign=result['sunsign'],
horoscope=result['horoscope'])

#Current Month Horoscope
@app.route ('/horoscope/month/<sunsign>', methods=['GET'])
def monthly_horoscope_route (sunsign) :
result = dict (Horoscope.get_monthly_horoscope (sunsign))
return jsonify (month=result['month'],
sunsign=result['sunsign'],
horoscope=result['horoscope'])

#Current Year Horoscope
@app.route ('/horoscope/year/<sunsign>', methods=['GET'])
def yearly_horoscope_route (sunsign) :
result = dict (Horoscope.get_yearly_horoscope (sunsign))
return jsonify (year=result['year'],
sunsign=result['sunsign'],
horoscope=result['horoscope'])


###########################################
# More Information About A Sunsign
###########################################

@app.route ('/knowmore/<sunsign>', methods=['GET'])
def know_more_route (sunsign) :
result = dict (Horoscope.know_all_about (sunsign))
return jsonify (sanskrit_name=result['sanskrit_name'],
meaning_of_name=result['meaning_of_name'],
lord=result['lord'],
lucky_color=result['lucky_color'],
lucky_day=result['lucky_day'],
lucky_number=result['lucky_number'])


###########################################
#Start Flask
###########################################

if __name__ == "__main__":
app.run()


















































0 comments on commit 203be8f

Please sign in to comment.