INNER CODE UNIT · Python

allowed_file

project-sekai-ctf/sekaictf-2025 · pwn/umiyuri-kaikeitan/challenge/app/app.py:54

def allowed_file(filename):
    return (
        "." in filename
        and filename.rsplit(".", 1)[1].lower() in app.config["ALLOWED_EXTENSIONS"]
    )


@app.route("/", methods=["GET", "POST"])
def upload_file():
    form = UploadForm()
    if form.validate_on_submit():
        file = form.file.data
        if file and allowed_file(file.filename):
            # Save file to the tmp folder
            filename = secure_filename(file.filename)
            filepath = os.path.join(app.config["UPLOAD_FOLDER"], filename)
            file.save(filepath)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…