Skip to content

Instantly share code, notes, and snippets.

View souravs17031999's full-sized avatar
💭
print("No coffee ! Only Data ! ")

Sourav Kumar souravs17031999

💭
print("No coffee ! Only Data ! ")
View GitHub Profile
# syntax=docker/dockerfile:1
FROM python:3.8-alpine
WORKDIR /app
COPY requirements.txt requirements.txt
RUN python3 -m pip install -r requirements.txt --no-cache-dir
def send_twilio_notifications(message_body):
try:
print("[TWILIO] : sending SMS to user ")
print("[TWILIO] : message for SMS: ")
print(message_body)
message = client.messages.create(
body=message_body,
from_=TWILIO_PHONE_USER_SENDER,
to=TWILIO_PHONE_USER_RECEIVER
def get_message_for_twilio_SMS(json_response, current_price_of_product):
productTitle = json_response["product"]["title"][:30]
productId = json_response["product"]["asin"]
productBuyLink = json_response["product"]["link"]
messageBody = f"Hurry up ! Your requested Product {productTitle} is available within your budget for rs. {current_price_of_product}. Click on link now to order it. \
{productBuyLink}"
return messageBody
def get_amazon_product_response():
apiParams = {
'api_key': AMAZON_API_KEY,
'type': 'product',
'amazon_domain': 'amazon.in',
'asin': 'B093L8FSP2',
'output': 'json'
}
headers = {"Content-Type": "application/json"}
def trigger_amazon_product_price_notifications():
print(
"*********************** CRON for sending notifications for AMAZON Offers deal of the day ********************"
)
datetime_NY = datetime.datetime.now(tz_AK)
print("[CRON TIME (IST)]: ", datetime_NY.strftime("%A, %d %B %Y %I:%M%p"))
print("[CRON TIME (UTC)]: ", datetime.datetime.utcnow())
try:
// user should be authenticated on initial loading of page and then set user data in context on the page
window.onload = initialPageLoad
function initialPageLoad() {
fetchUserData(user_id);
}
function fetchUserData(user_id) {
mail_body = generate_mail_content("mail.html)
message = Mail(
from_email=sender_email,
to_emails=receiver_email,
subject=subject,
html_content=mail_body)
try:
sendgridAPIClientKey = os.getenv('SENDGRID_API_KEY')
sg = SendGridAPIClient(sendgridAPIClientKey)
def generate_mail_content(template_name, **template_vars):
templateLoader = jinja2.FileSystemLoader(searchpath="templates")
templateEnv = jinja2.Environment(loader=templateLoader)
template = templateEnv.get_template(template_name)
return template.render(**template_vars)
from flask import Flask, json, jsonify, request, Response, Blueprint
import psycopg2
app = Flask(__name__)
user = Blueprint('user', __name__)
DATABASE_URL = "postgresql://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]"
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
from flask import Flask, jsonify, request
from views.user import user
app = Flask(__name__)
app.register_blueprint(user, url_prefix='/user')
@app.before_request
def before_request_func():