-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
55 lines (43 loc) · 1.78 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from flask import Flask, render_template, request, jsonify
from dotenv import load_dotenv
import openai
import os
openai.api_key = os.getenv("OPENAI_API_KEY")
from openai_script_generator import generate_script
# Load environment variables from .env file
app = Flask(__name__)
load_dotenv()
@app.route('/', methods=['GET', 'POST'])
def home():
if request.method == 'POST':
# Process the form data here and generate the script
persona = request.form.get('persona', '')
episode_theme = request.form.get('episode_theme', '')
intro_clip = request.form.get('intro_clip', '')
episode_num = request.form.get('episode_num', '')
guest_name = request.form.get('guest_name', '')
guest_intro = request.form.get('guest_intro', '')
commercial_break = request.form.get('commercial_break', '')
# Generate the script
script = generate_script(persona, episode_theme, intro_clip, episode_num, guest_name, guest_intro, commercial_break)
# Render the template with the generated script
return render_template('home.html', script=script)
else:
return render_template('home.html')
if __name__ == '__main__':
app.run()
@app.route('/result', methods=['POST'])
def result():
data = request.get_json()
persona = data['persona']
episode_theme = data['episode_theme']
intro_clip = data['intro_clip']
episode_num = data['episode_num']
guest_name = data['guest_name']
guest_intro = data['guest_intro']
commercial_break = data['commercial_break']
# Generate the script
script = generate_script( persona, episode_theme, intro_clip, episode_num, guest_name, guest_intro, commercial_break)
return jsonify({'script': script})
if __name__ == '__main__':
app.run(debug=True)