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, send_file, request | |
app = Flask(__name__) | |
@app.route('/download-file/<file_id>') | |
def download_file(file_id): | |
# Construct file path using file ID | |
file_path = f'path/to/your/files/{file_id}.extension' | |
# Serve the file for download | |
return send_file(file_path, as_attachment=True, download_name=f'{file_id}.extension') |
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, send_file | |
app = Flask(__name__) | |
@app.route('/download-file') | |
def download_file(): | |
# Path to the file you want to serve up | |
path_to_file = 'path/to/your/file.extension' | |
# Serve the file for download | |
return send_file(path_to_file, as_attachment=True) |
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
# Command to convert MP3 to M4A for broad compatibility, especially with iOS devices | |
ffmpeg -i input.mp3 -acodec aac output.m4a | |
# Remember to replace `input.mp3` and `output.m4a` with your actual file names. |
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 twilio.rest import Client | |
# Twilio credentials | |
account_sid = 'YOUR_ACCOUNT_SID' | |
auth_token = 'YOUR_AUTH_TOKEN' | |
# Your Twilio phone number | |
from_phone_number = 'TWILIO_PHONE_NUMBER' | |
# Recipient's phone number |
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
def auto_cot(prompt, model): | |
# Initialize an empty list to store reasoning steps | |
reasoning_steps = [] | |
# Generate initial reasoning step | |
current_step = model.generate_initial_step(prompt) | |
while not is_final_step(current_step): | |
# Append the current reasoning step to the list | |
reasoning_steps.append(current_step) | |
# Use the current reasoning step as the next prompt | |
prompt = form_next_prompt(current_step) |
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, request | |
from threading import Thread | |
app = Flask(__name__) | |
def async_task(data): | |
# Your async operation here, e.g., process data | |
pass | |
@app.route('/webhook', methods=['POST']) |
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, request | |
app = Flask(__name__) | |
@app.route('/webhook', methods=['POST']) | |
def webhook(): | |
# Assuming the incoming request is a form with 'MediaUrl0' for the first media item | |
media_url = request.form.get('MediaUrl0') | |
print(f'Media URL: {media_url}') |
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 twilio.rest import Client | |
# Twilio credentials | |
account_sid = 'your_account_sid' | |
auth_token = 'your_auth_token' | |
client = Client(account_sid, auth_token) | |
# Fetch a specific message by SID | |
message_sid = 'SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
message = client.messages(message_sid).fetch() |
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 whisper | |
model = whisper.load_model("base") | |
# Load your audio file | |
audio_path = "path/to/your/audio.mp3" | |
# Transcribe the audio file | |
def transcribe_audio(audio_path): | |
result = model.transcribe(audio_path) |
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
def flattener(array_to_flatten) | |
array_to_flatten.each_with_object([]) do |array_element, flat_array| | |
flat_array.push *(array_element.is_a?(Array) ? flattener(array_element) : array_element) | |
end | |
end |
NewerOlder