Created
May 12, 2024 20:04
-
-
Save iliasmachairas/43338f2c5e6fea5d7f6742ad4814f187 to your computer and use it in GitHub Desktop.
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
from flask import Flask, render_template, request, redirect, url_for | |
from twilio.rest import Client | |
# Your Twilio Account SID and Auth Token | |
account_sid = 'your_account_sid' | |
auth_token = 'your_auth_toekn' | |
# Initialize Twilio client | |
client = Client(account_sid, auth_token) | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
return render_template('form.html') | |
@app.route('/submit', methods=['POST']) | |
def submit(): | |
name = request.form['name'] | |
date = request.form['date'] | |
location = request.form['location'] | |
return redirect(url_for('result', name=name, date=date, location=location)) | |
@app.route('/result') | |
def result(): | |
name = request.args.get('name') | |
date = request.args.get('date') | |
location = request.args.get('location') | |
message = client.messages.create( | |
body='Details of appointment. Name: '+name+ ', date: '+date+ ' ,location: '+location, | |
from_='your_twilio_number', | |
to='recipient_phone_number' | |
) | |
print("Message sent successfully. SID:", message.sid) | |
return render_template('result.html', name=name, date=date, location=location) | |
if __name__ == '__main__': | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment