app.py
def article_start():
    """Display the article, including calling the processing of it"""
    #Getting from article:
    POST_name = request.form["page"] #Article name input by user
    language = request.form["lang"] #Wikipedia language input by user
    (filtered_name,if_error,error) = filter_title.handle_input_title_language(POST_name,language)
    if if_error:
        return render_template("index.html",error_message = error)

    #Settings checkboxes. These are only delivered by POST if they are checked, so assume they are False unless delivered:
    if_quote = if_cardinal_number = if_singular_proper_noun = if_noun = if_adjective = False
    if_attach_all_citations = True
    if request.form.get("ifDefaultSettings"):
        if_quote = if_cardinal_number = if_singular_proper_noun = True
        if_attach_all_citations = False
    else:
        if request.form.get("attach_all_citations_check"):
            if_quote = False
        if request.form.get("quote_check"):
            if_quote = True
        if request.form.get("CD_check"):
            if_cardinal_number = True
        if request.form.get("NNP_check"):
            if_singular_proper_noun = True
        if request.form.get("NN_check"):
            if_noun = True
        if request.form.get("JJ_check"):
            if_adjective = True
    settings = {
        "language": language,
        "quote?": if_quote,
        "CD?": if_cardinal_number,
        "NNP?": if_singular_proper_noun,
        "NN?": if_noun,
        "JJ?": if_adjective
    }

    #Finished checks
    #Submit to backend:
    data = { #No data yet
            "segment": 0,
            "segment_last": 0,
            "external_URLs": [],
            "text_segments": [],
            "section_ends": [],
            "citation_data": [], # Position of each citation in the original wikitext
            "processed_tags": [],
            "processed_citations": dict(), # Text and tagged words of each citation URL
            "errors": "",
            "if_attach_all_citations": if_attach_all_citations,
            "reprocess?": False
    }
    data = main.main(filtered_name,data,settings)
    session['filtered_name'] = filtered_name
    session['data'] = data
    session['settings'] = settings

    #Using backend output, render HTML:
    if(data['errors']=="500"): #Generic server error
        return render_template("index.html",
                               error_message = "The article does not exist (title is case-sensitive), or another error occurred.")
    elif(data['errors']=="_ERROR: problem getting external_URLs_"): 
        error_message = "A problem occurred grabbing the citations from Wikipedia, please try again. This error has been recorded."
        return render_template("index.html",
                               error_message = error_message)
    return render_template("article_start.html",
                        page=filtered_name,
                        language=language
                        )
Display the article, including calling the processing of it
Display the article, including calling the processing of it
Display the article including calling the processing of it
def article_start():
    POST_name = request.form["page"] 
    language = request.form["lang"] 
    (filtered_name,if_error,error) = filter_title.handle_input_title_language(POST_name,language)
    if if_error:
        return render_template("index.html",error_message = error)
    if_quote = if_cardinal_number = if_singular_proper_noun = if_noun = if_adjective = False
    if_attach_all_citations = True
    if request.form.get("ifDefaultSettings"):
        if_quote = if_cardinal_number = if_singular_proper_noun = True
        if_attach_all_citations = False
    else:
        if request.form.get("attach_all_citations_check"):
            if_quote = False
        if request.form.get("quote_check"):
            if_quote = True
        if request.form.get("CD_check"):
            if_cardinal_number = True
        if request.form.get("NNP_check"):
            if_singular_proper_noun = True
        if request.form.get("NN_check"):
            if_noun = True
        if request.form.get("JJ_check"):
            if_adjective = True
    settings = {
        "language": language,
        "quote?": if_quote,
        "CD?": if_cardinal_number,
        "NNP?": if_singular_proper_noun,
        "NN?": if_noun,
        "JJ?": if_adjective
    }
    data = { 
            "segment": 0,
            "segment_last": 0,
            "external_URLs": [],
            "text_segments": [],
            "section_ends": [],
            "citation_data": [], 
            "processed_tags": [],
            "processed_citations": dict(), 
            "errors": "",
            "if_attach_all_citations": if_attach_all_citations,
            "reprocess?": False
    }
    data = main.main(filtered_name,data,settings)
    session['filtered_name'] = filtered_name
    session['data'] = data
    session['settings'] = settings
    if(data['errors']=="500"): 
        return render_template("index.html",
                               error_message = "The article does not exist (title is case-sensitive), or another error occurred.")
    elif(data['errors']=="_ERROR: problem getting external_URLs_"): 
        error_message = "A problem occurred grabbing the citations from Wikipedia, please try again. This error has been recorded."
        return render_template("index.html",
                               error_message = error_message)
    return render_template("article_start.html",
                        page=filtered_name,
                        language=language
                        )
def article_start ( ) : POST_name = request . form [ "page" ] language = request . form [ "lang" ] ( filtered_name , if_error , error ) = filter_title . handle_input_title_language ( POST_name , language ) if if_error : return render_template ( "index.html" , error_message = error ) if_quote = if_cardinal_number = if_singular_proper_noun = if_noun = if_adjective = False if_attach_all_citations = True if request . form . get ( "ifDefaultSettings" ) : if_quote = if_cardinal_number = if_singular_proper_noun = True if_attach_all_citations = False else : if request . form . get ( "attach_all_citations_check" ) : if_quote = False if request . form . get ( "quote_check" ) : if_quote = True if request . form . get ( "CD_check" ) : if_cardinal_number = True if request . form . get ( "NNP_check" ) : if_singular_proper_noun = True if request . form . get ( "NN_check" ) : if_noun = True if request . form . get ( "JJ_check" ) : if_adjective = True settings = { "language" : language , "quote?" : if_quote , "CD?" : if_cardinal_number , "NNP?" : if_singular_proper_noun , "NN?" : if_noun , "JJ?" : if_adjective } data = { "segment" : 0 , "segment_last" : 0 , "external_URLs" : [ ] , "text_segments" : [ ] , "section_ends" : [ ] , "citation_data" : [ ] , "processed_tags" : [ ] , "processed_citations" : dict ( ) , "errors" : "" , "if_attach_all_citations" : if_attach_all_citations , "reprocess?" : False } data = main . main ( filtered_name , data , settings ) session [ 'filtered_name' ] = filtered_name session [ 'data' ] = data session [ 'settings' ] = settings if ( data [ 'errors' ] == "500" ) : return render_template ( "index.html" , error_message = "The article does not exist (title is case-sensitive), or another error occurred." ) elif ( data [ 'errors' ] == "_ERROR: problem getting external_URLs_" ) : error_message = "A problem occurred grabbing the citations from Wikipedia, please try again. This error has been recorded." return render_template ( "index.html" , error_message = error_message ) return render_template ( "article_start.html" , page = filtered_name , language = language )
Display the article, including calling the processing of it
Display the article including calling the processing of it
"""Display the article, including calling the processing of it""" #Getting from article: #Article name input by user #Wikipedia language input by user #Settings checkboxes. These are only delivered by POST if they are checked, so assume they are False unless delivered: #Finished checks #Submit to backend: #No data yet # Position of each citation in the original wikitext # Text and tagged words of each citation URL #Using backend output, render HTML: #Generic server error