Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9267303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:31:10+00:00 2026-06-18T14:31:10+00:00

I need to get a list from the serverside in python 2.7 to the

  • 0

I need to get a list from the serverside in python 2.7 to the front-end in javascript to print them. Is there a way to do this? I tried to pass the list through “self.response.out.write(my_list)”.

import webapp2
import jinja2
import os
import logging
from google.appengine.ext import db
import random
from google.appengine.api import users
jinja_environment = jinja2.Environment(
    loader=jinja2.FileSystemLoader(os.path.dirname(__file__) + '/template'))

class MainPage(webapp2.RequestHandler):
    def get(self):
      # Print webpage
      template_values = {}
      template = jinja_environment.get_template('index.html')
      self.response.out.write(template.render(template_values))

    def post(self):
      my_list = ['one', 'two', 'three', 'four']
      self.response.out.write(my_list)


app = webapp2.WSGIApplication([('/', MainPage),],debug=True)

Javascript code to loop through list and print them in console.

function refresh(e) {
    console.log('Refresh.');
    addNewWord();
}

function addNewWord() {
    console.log('Add new words');
    $.ajax('/',{
        type: 'POST',
        data: {

        },
        success: handleResponse
    });
}

function handleResponse(data) {
    console.log('Got from server:' + data);
    for (var i = 0; i <data.length; i++) {
        console.log(data[i]);
    }
}

$(document).ready(function() {
    $('#refreshButton').click(refresh);
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:31:12+00:00Added an answer on June 18, 2026 at 2:31 pm

    The best way to send and proces a list or Python object with JavaScript is to send JSON.
    You can use json.dumps in your python code

    import json
    ....
    
    my_list = ['one', 'two', 'three', 'four']
    self.response.write(json.dumps(my_list)
    

    Now you receive a JSON string. But using jQuery it will give you a JavaScript object. See jQuery for the details: http://api.jquery.com/jQuery.getJSON/

    If you don not use JSON, you can use a string to send the list :

    my_list = ['one', 'two', 'three', 'four']
    self.response.write(','.join(my_list))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get items from a html list from the vb.net code behind
i need to get items from a List with no leading or trailing white
I get a list of items from my Repository. Now I need to sort
I need to get a List from a query involving a view. Here's the
n00b here, be patient:) I need to get a list of jpgs from my
Can we access Mails List from iphone Mail app. I need to get a
i have a problem with sql query. I need to get list of users.
I need a get a list of all databases in a Couchdb server inside
I need to get a list of all tables that are published for replication
I need to get a list of tags in a text, make their contents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.