def get_yearly_horoscope(sunsign): if not is_valid_sunsign(sunsign): return jsonify({ 'status': 400, 'error': 'bad request', 'message': 'Invalid sunsign' }), 400 horoscope = Horoscope(sunsign) return jsonify(horoscope.yearly())
def send_daily_horoscope(sunsign): data = request.get_json(force=True) account_sid = data.get('account_sid', None) if account_sid is None: return jsonify({ 'status': 400, 'error': 'bad request', 'message': 'Twilio account sid required' }), 400 auth_token = data.get('auth_token', None) if auth_token is None: return jsonify({ 'status': 400, 'error': 'bad request', 'message': 'Twilio auth token required' }), 400 from_phone = data.get('from_phone', None) if from_phone is None: return jsonify({ 'status': 400, 'error': 'bad request', 'message': 'Twilio phone number required' }), 400 to_phone = data.get('to_phone', None) if to_phone is None: return jsonify({ 'status': 400, 'error': 'bad request', 'message': 'To phone number required' }), 400 if not is_valid_sunsign(sunsign): return jsonify({ 'status': 400, 'error': 'bad request', 'message': 'Invalid sunsign' }), 400 horoscope = Horoscope(sunsign) today = horoscope.daily() message = "%s: %s" % (sunsign.upper(), today['horoscope']) twilio_response = send_message(account_sid, auth_token, from_phone, to_phone, message) if not twilio_response: return jsonify({ 'status': 400, 'error': 'bad request', 'message': 'Twilio API details required' }), 400 return jsonify({'message': twilio_response})
def send_daily_horoscope(sunsign): data = request.get_json(force=True) account_sid = data.get('account_sid', None) if account_sid is None: return jsonify({'status': 400, 'error': 'bad request', 'message': 'Twilio account sid required'}), 400 auth_token = data.get('auth_token', None) if auth_token is None: return jsonify({'status': 400, 'error': 'bad request', 'message': 'Twilio auth token required'}), 400 from_phone = data.get('from_phone', None) if from_phone is None: return jsonify({'status': 400, 'error': 'bad request', 'message': 'Twilio phone number required'}), 400 to_phone = data.get('to_phone', None) if to_phone is None: return jsonify({'status': 400, 'error': 'bad request', 'message': 'To phone number required'}), 400 if not is_valid_sunsign(sunsign): return jsonify({'status': 400, 'error': 'bad request', 'message': 'Invalid sunsign'}), 400 horoscope = Horoscope(sunsign) today = horoscope.daily() message = "%s: %s" % (sunsign.upper(), today['horoscope']) twilio_response = send_message(account_sid, auth_token, from_phone, to_phone, message) if not twilio_response: return jsonify({'status': 400, 'error': 'bad request', 'message': 'Twilio API details required'}), 400 return jsonify({'message': twilio_response})
def get_yearly_horoscope(sunsign): if not is_valid_sunsign(sunsign): return jsonify({'status': 400, 'error': 'bad request', 'message': 'Invalid sunsign'}), 400 horoscope = Horoscope(sunsign) return jsonify(horoscope.yearly())
from astrosage import Horoscope from pprint import pprint h = Horoscope('aquarius') pprint(h.daily()) # pprint(h.weekly()) # pprint(h.monthly()) # pprint(h.yearly()) # pprint(h.weekly_love())