Created
December 28, 2021 12:21
-
-
Save skolo-online/db237555e6c51a322625851d0ace4af5 to your computer and use it in GitHub Desktop.
Flask application - AI Blog Writing Tool
This file contains hidden or 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, 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