app.py
def article_named(POST_name):
    """Alternate method of inputting title, allowing /article/<article name> and /article/<Wikipedia page URL>"""
    #Defaults:
    language = "en"
    if_noun = if_adjective = False
    if_quote = if_cardinal_number = if_singular_proper_noun = True
    
    #/article/<Wikipedia page URL> :
    if ".wikipedia.org/wiki/" in POST_name:
        (language, POST_name) = filter_title.from_url(POST_name)
    (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 = {
        "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": False,
            "reprocess?": False
    }
    data = main.main(filtered_name,data,settings)
    filtered_name = filtered_name.replace("_"," ") #Remove possible _'s in title before showing on screen
    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.html",
                        page=filtered_name,
                        language=language
                        )
Alternate method of inputting title, allowing /article/<article name> and /article/<Wikipedia page URL>
Alternate method of inputting title, allowing /article/ and /article/
Alternate method of inputting title allowing / article / and / article /
def article_named(POST_name):
    language = "en"
    if_noun = if_adjective = False
    if_quote = if_cardinal_number = if_singular_proper_noun = True
    if ".wikipedia.org/wiki/" in POST_name:
        (language, POST_name) = filter_title.from_url(POST_name)
    (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 = {
        "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": False,
            "reprocess?": False
    }
    data = main.main(filtered_name,data,settings)
    filtered_name = filtered_name.replace("_"," ") 
    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.html",
                        page=filtered_name,
                        language=language
                        )
def article_named ( POST_name ) : language = "en" if_noun = if_adjective = False if_quote = if_cardinal_number = if_singular_proper_noun = True if ".wikipedia.org/wiki/" in POST_name : ( language , POST_name ) = filter_title . from_url ( POST_name ) ( 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 = { "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" : False , "reprocess?" : False } data = main . main ( filtered_name , data , settings ) filtered_name = filtered_name . replace ( "_" , " " ) 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.html" , page = filtered_name , language = language )
Alternate method of inputting title, allowing /article/<article name> and /article/<Wikipedia page URL>
Alternate method of inputting title allowing / article / <article name > and / article / <Wikipedia page URL >
"""Alternate method of inputting title, allowing /article/<article name> and /article/<Wikipedia page URL>""" #Defaults: #/article/<Wikipedia page URL> : #Finished checks #Submit to backend: #No data yet # Position of each citation in the original wikitext # Text and tagged words of each citation URL #Remove possible _'s in title before showing on screen #Using backend output, render HTML: #Generic server error
POST_name