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)
[((7, 8, 7, 19), 'time.time', 'time.time', ({}, {}), '()', False, 'import time\n'), ((8, 6, 8, 21), 'flask.Flask', 'Flask', ({(8, 12, 8, 20): '__name__'}, {}), '(__name__)', False, 'from flask import Flask, request, redirect, url_for\n'), ((24, 4, 24, 59), 'os.system', 'os.system', ({(24, 14, 24, 58): 'f"""python3 generate.py {filename} "{text}\\""""'}, {}), '(f\'python3 generate.py {filename} "{text}"\')', False, 'import os\n'), ((19, 6, 19, 37), 'os.system', 'os.system', ({(19, 16, 19, 36): '"""rm static/images/*"""'}, {}), "('rm static/images/*')", False, 'import os\n'), ((20, 14, 20, 25), 'time.time', 'time.time', ({}, {}), '()', False, 'import time\n'), ((21, 11, 21, 39), 'flask.request.form.getlist', 'request.form.getlist', ({(21, 32, 21, 38): '"""text"""'}, {}), "('text')", False, 'from flask import Flask, request, redirect, url_for\n'), ((25, 20, 25, 68), 'flask.url_for', 'url_for', (), '', False, 'from flask import Flask, request, redirect, url_for\n'), ((18, 7, 18, 18), 'time.time', 'time.time', ({}, {}), '()', False, 'import time\n'), ((23, 23, 23, 48), 'random.choices', 'random.choices', (), '', False, 'import random\n')]