Skip to content

Instantly share code, notes, and snippets.

@skolo-online
Created January 17, 2022 06:56
Show Gist options
  • Save skolo-online/e83c5453018fc1316140f7ce6073329b to your computer and use it in GitHub Desktop.
Save skolo-online/e83c5453018fc1316140f7ce6073329b to your computer and use it in GitHub Desktop.
Content generator view function
from flask import Flask, render_template, request
import config
import aicontent
def page_not_found(e):
return render_template('404.html'), 404
app = Flask(__name__)
app.config.from_object(config.config['development'])
app.register_error_handler(404, page_not_found)
@app.route('/', methods=["GET", "POST"])
def index():
return render_template('index.html', **locals())
@app.route('/cold-emails', methods=["GET", "POST"])
def coldEmails():
if request.method == 'POST':
submission = request.form['coldEmails']
query = "Write a cold email to potential clients about: {}".format(submission)
openAIAnswerUnformatted = aicontent.openAIQuery(query)
openAIAnswer = openAIAnswerUnformatted.replace('\n', '<br>')
prompt = 'AI Suggestions for {} are:'.format(submission)
return render_template('cold-emails.html', **locals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment