from flask import Flask, request, redirect, url_for
import os
import random
import string
import time # lemonthink

clean = time.time()
app = Flask(__name__)
chars = list(string.ascii_letters + string.digits)

@app.route('/')
def main():
    return open("index.html").read()

@app.route('/generate', methods=['POST'])
def upload():
    global clean
    if time.time() - clean > 60:
      os.system("rm static/images/*")
      clean = time.time()
    text = request.form.getlist('text')[0]
    text = text.replace("\"", "")
    filename = "".join(random.choices(chars,k=8)) + ".png"
    os.system(f"python3 generate.py {filename} \"{text}\"")
    return redirect(url_for('static', filename='images/' + filename), code=301)
[((124, 135), 'time.time', 'time.time', ([], {}), '()\n', (133, 135), False, 'import time\n'), ((142, 157), 'flask.Flask', 'Flask', (['__name__'], {}), '(__name__)\n', (147, 157), False, 'from flask import Flask, request, redirect, url_for\n'), ((586, 639), 'os.system', 'os.system', (['f"""python3 generate.py {filename} "{text}\\""""'], {}), '(f\'python3 generate.py {filename} "{text}"\')\n', (595, 639), False, 'import os\n'), ((388, 419), 'os.system', 'os.system', (['"""rm static/images/*"""'], {}), "('rm static/images/*')\n", (397, 419), False, 'import os\n'), ((434, 445), 'time.time', 'time.time', ([], {}), '()\n', (443, 445), False, 'import time\n'), ((457, 485), 'flask.request.form.getlist', 'request.form.getlist', (['"""text"""'], {}), "('text')\n", (477, 485), False, 'from flask import Flask, request, redirect, url_for\n'), ((662, 710), 'flask.url_for', 'url_for', (['"""static"""'], {'filename': "('images/' + filename)"}), "('static', filename='images/' + filename)\n", (669, 710), False, 'from flask import Flask, request, redirect, url_for\n'), ((356, 367), 'time.time', 'time.time', ([], {}), '()\n', (365, 367), False, 'import time\n'), ((546, 572), 'random.choices', 'random.choices', (['chars'], {'k': '(8)'}), '(chars, k=8)\n', (560, 572), False, 'import random\n')]