Exemple #1
0
def handle_pinyinfix():
    start_time = time.time()
    pinyin = get_parameter("pinyin", "")
    if len(pinyin) > 100000:
        context = create_context(
            start_time,
            error="Sorry, that text is too big; It will consume too much server CPU time to process. " \
                  "You can try reaching out to [email protected] or set this script up on your own dedicated server."
        )
        return render_template("error.html", **context)
    fixed, fixed_count = fix_pinyin(pinyin)
    context = create_context(start_time,
                             pinyin=pinyin,
                             fixed=fixed,
                             fixed_count=fixed_count)
    return render_template("pinyinfix.html", **context)
def homophones_page(expand, hsk_only, match_tones, num_chars, start_time):
    homophones = build_homophones(num_chars, match_tones, hsk_only)
    context = create_context(
        start_time,
        num_chars=num_chars,
        expand=expand,
        match_tones=match_tones,
        hsk_only=hsk_only,
        homophones=homophones,
        link_1=homophones_link(1, expand, match_tones, hsk_only),
        link_2=homophones_link(2, expand, match_tones, hsk_only),
        link_3=homophones_link(3, expand, match_tones, hsk_only),
        link_4=homophones_link(4, expand, match_tones, hsk_only),
        link_5=homophones_link(5, expand, match_tones, hsk_only),
        link_6=homophones_link(6, expand, match_tones, hsk_only),
        link_7=homophones_link(7, expand, match_tones, hsk_only),
        link_8=homophones_link(8, expand, match_tones, hsk_only),
        link_9=homophones_link(9, expand, match_tones, hsk_only),
        link_expand=homophones_link(num_chars, not expand, match_tones,
                                    hsk_only),
        link_match_tones=homophones_link(num_chars, expand, not match_tones,
                                         hsk_only),
        link_hsk_only=homophones_link(num_chars, expand, match_tones,
                                      not hsk_only))
    return render_template("homophones.html", **context)
Exemple #3
0
def handle_root():
    start_time = time.time()
    context = create_context(start_time)
    return render_template("root.html", **context)