#!/usr/bin/env python3

from flask import Flask, render_template_string, request

app = Flask(__name__)

@app.route('/')
def index():
    return ("\x3cpre\x3e\x3ccode\x3e%s\x3c/code\x3e\x3c/pre\x3e")%open(__file__).read()

@app.route('/check')
def check():
    flag = open("flag.txt", 'r').read().strip()
    query = request.args["flag"]
    if not query.startswith("ictf{") or not query.endswith("}"):
        return "Bad flag format!"
    if len(query) != len(flag):
        return "Bad length!"
    try: 
        return render_template_string('{{ flag == "%s" }}'%query, flag=flag)
    except:
        return "False"

app.run('0.0.0.0', 4000)