Skip to content

Instantly share code, notes, and snippets.

@skolo-online
Created December 28, 2021 12:21
Show Gist options
  • Select an option

  • Save skolo-online/db237555e6c51a322625851d0ace4af5 to your computer and use it in GitHub Desktop.

Select an option

Save skolo-online/db237555e6c51a322625851d0ace4af5 to your computer and use it in GitHub Desktop.
Flask application - AI Blog Writing Tool
from flask import Flask, render_template, request
import config
import blog
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():
if request.method == 'POST':
if 'form1' in request.form:
prompt = request.form['blogTopic']
blogT = blog.generateBlogTopics(prompt)
blogTopicIdeas = blogT.replace('\n', '<br>')
if 'form2' in request.form:
prompt = request.form['blogSection']
blogT = blog.generateBlogSections(prompt)
blogSectionIdeas = blogT.replace('\n', '<br>')
if 'form3' in request.form:
prompt = request.form['blogExpander']
blogT = blog.blogSectionExpander(prompt)
blogExpanded = blogT.replace('\n', '<br>')
return render_template('index.html', **locals())
if __name__ == '__main__':
app.run(host='0.0.0.0', port='8888', debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment