introduced loggin
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
thread-killer.py
|
thread-killer.py
|
||||||
|
log.txt
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|||||||
10
app.py
10
app.py
@@ -1,5 +1,7 @@
|
|||||||
from flask import Flask, render_template, request
|
from flask import Flask, render_template, request
|
||||||
from main import get_auto_transcript, get_video_id, create_and_stream
|
from main import get_auto_transcript, get_video_id, create_and_stream
|
||||||
|
from datetime import datetime
|
||||||
|
import pytz
|
||||||
|
|
||||||
app = Flask(__name__, static_folder="website/static", template_folder="website")
|
app = Flask(__name__, static_folder="website/static", template_folder="website")
|
||||||
|
|
||||||
@@ -9,6 +11,8 @@ def home():
|
|||||||
|
|
||||||
@app.route('/process_url', methods=['POST'])
|
@app.route('/process_url', methods=['POST'])
|
||||||
def process_url():
|
def process_url():
|
||||||
|
# Opens a file to log the video id and the assistants respone to see if I can further improve instructions:
|
||||||
|
log = open("log.txt", "at", 1)
|
||||||
url = request.form['url']
|
url = request.form['url']
|
||||||
|
|
||||||
# Extract the video ID from the URL
|
# Extract the video ID from the URL
|
||||||
@@ -22,10 +26,10 @@ def process_url():
|
|||||||
return "Successfully parsed video ID from URL, however the ID was either invalid, the transcript was disabled by the video owner, or some other error was raised because of YouTube."
|
return "Successfully parsed video ID from URL, however the ID was either invalid, the transcript was disabled by the video owner, or some other error was raised because of YouTube."
|
||||||
|
|
||||||
# Process the transcript and stream the result.
|
# Process the transcript and stream the result.
|
||||||
stream = create_and_stream(transcript)
|
response = create_and_stream(transcript)
|
||||||
|
log.write(f"\n\n\n### New Entry at {datetime.now(pytz.timezone('America/New_York')).strftime('%Y-%m-%d %H:%M:%S')}\n\n URL: {url}\n Video ID: {video_id}\n\nAssistant Response: {response}")
|
||||||
# Return a response
|
# Return a response
|
||||||
return stream # Add more detailed output if needed
|
return response # Add more detailed output if needed
|
||||||
|
|
||||||
if __name__ == '__main__': # Change this line to properly check for main
|
if __name__ == '__main__': # Change this line to properly check for main
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
Reference in New Issue
Block a user