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 7706423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:07:20+00:00 2026-06-01T00:07:20+00:00

I am new to both GAE and PiCould, and have some basic questions when

  • 0

I am new to both GAE and PiCould, and have some basic questions when I would like to call a published function from GAE. It seems like my approach of calling a published function is not recognized. So can you give me some suggestions?

Thanks for your help!

UPDATE: I am not sure why people think this question is not valuable. My standing point is that since GAE only accept pure-Python file, it is necessary to find a way for models written in other langurages (i.e., Fortran77). Thus, some non-Python programs can be uploaded to other cloud servers such like PiCloud and then called by GAE. With people’s help (thank you!) I have figured out this issue. I have attached my codes below for other’s reference:

import os
os.environ['DJANGO_SETTINGS_MODULE']='settings'
from google.appengine.ext.webapp.util import run_wsgi_app
import webapp2 as webapp
import json
import base64
#import urllib2
import urllib

from google.appengine.api import urlfetch

api_key='1111'
api_secretkey='adsad'

####define and publish a function######
def square(x):
    """Returns square of a number"""
    print 'Squaring %d' % x
    return x*x

cloud.setkey(api_key, api_secretkey)
cloud.rest.publish(square, "square_func")

url = 'https://' + 'api.picloud.com/r/3303/square_func' 
input_val=22

#######call the function################# 
base64string = base64.encodestring('%s:%s' % (api_key, api_secretkey))[:-1]
http_headers = {'Authorization' : 'Basic %s' % base64string}
data = urllib.urlencode({"x":input_val})
response = urlfetch.fetch(url=url, payload=data, method=urlfetch.POST, headers=http_headers)

jid= json.loads(response.content)['jid']
output_st = 'queued'
#
while output_st=="queued":
    response_st = urlfetch.fetch(url='https://api.picloud.com/job/?jids=%s&field=status' %jid, headers=http_headers)
    output_st = str(json.loads(response_st.content)['info']['%s' %jid]['status'])

url_val = 'https://api.picloud.com/job/result/?jid='+str(jid)
response_val = urlfetch.fetch(url=url_val, method=urlfetch.GET, headers=http_headers)
output_val = json.loads(response_val.content)['result']


class Page(webapp.RequestHandler):
    def get(self):
        html = """<table width="600" border="1">
                          <tr>
                            <th width="480" scope="col">Outputs</div></th>
                            <th width="120" scope="col">Value</div></th>                            
                          </tr>
                          <tr>
                            <td>Input</td>
                            <td>%s</td></tr>                          
                          <tr>
                            <td>picloud jid</td>
                            <td>%s</td></tr>
                          <tr>
                            <td>picloud status</td>
                            <td>%s</td></tr>
                          <tr>
                            <td>picloud results</td>
                            <td>%s</td></tr>                             
                         </table>"""%(input_val, jid, output_st, output_val)

        self.response.out.write(html)

app = webapp.WSGIApplication([('/.*', Page)], debug=True)

def main():
    run_wsgi_app(app)

if __name__ == '__main__':
    main()
  • 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-01T00:07:22+00:00Added an answer on June 1, 2026 at 12:07 am

    The line should be:

    output_val = json.loads(response.content)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to both Pylons and AuthKit. I have basic authentication via AuthKit working
I'm new for both Sonar and Weld/CDI. I would like your help to advise
I am new to both Qt and Linux C++ development (although I have many
I'm new on both this site and ruby on rails! I have a common
I am new to both Ruby and ActiveRecord. I currently have a need to
I'm very new to both of these so please forgive my basic question. I
I am new to both WPF and WCF, and have a WPF app that
Being new to both .NET and Silverlight, I have noticed that many of the
I'm new to both git and OSX, coming from Ubuntu and svn. When I
I am new to both python, and to threads. I have written python code

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.