示例#1
0
def index():
    if request.method == 'GET':
        selected_languages = available_languages
    elif request.method == 'POST':
        selected_languages = request.form.getlist("languages")

    results = repos_with_most_stars(selected_languages)
    return render_template('index.html',
                           selected_languages=selected_languages,
                           availalble_languages=available_languages,
                           results=results)
示例#2
0
def index():
    if request.method == 'GET':
        # code for a GET
        # use the list of all languages
        selected_languages = available_languages
    elif request.method == 'POST':
        # code for a post
        # Use the languages we selected in the request form
        selected_languages = request.form.getlist("languages")

    results = repos_with_most_stars(selected_languages)

    return render_template('index.html',
                           selected_languages=selected_languages,
                           available_languages=available_languages,
                           results=results)
示例#3
0
def index():
    # this signals to Flask that this index() function should be
    # called to handle any GET or POST requests to the URL /.

    if request.method == "GET":
        # display whichever repos were selected last
        # (or all of them if this is the first request)
        selected_languages = available_languages
    elif request.method == "POST":
        # grab the languages variable from the request form
        # and use it to populate our selected_languages list
        selected_languages = request.form.getlist("languages")

    results = repos_with_most_stars(selected_languages)

    # pass to render_template the list of selected languages, available languages and results:
    return render_template(
        "index.html",
        selected_languages=selected_languages,
        available_languages=available_languages,
        results=results
    )