from flask import Flask, request, render_template
from requests import post
from bs4 import BeautifulSoup
app = Flask(__name__)
@app.route('/main', methods=['GET', 'POST'])
def index():
if request.method == 'GET':
return render_template('index.html')
elif request.method == 'POST':
word = request.form.get('word')
sizes = request.form.get('sizes')
fonts = request.form.get('fonts')
fontcolor = request.form.get('fontcolor')
data = {
'word': word,
'sizes': sizes,
'fonts': fonts,
'fontscolor': fontcolor,
}
html = post('http://www.uustv.com/', data=data).text
dom = BeautifulSoup(html, 'html5lib')
img_url = dom.find_all('div', 'tu')[0].img['src']
apath = 'http://www.uustv.com/' + img_url
return render_template('index.html', apath=apath)
if __name__ == "__main__":
app.debug = True
app.run('127.0.0.1', 8092)