I'm trying to deploy a basic HelloWorld app on Google Engine following their tutorial for Python. I created a helloworld.py file and an app.yaml file and copied the code from their online tutorial. I signed up for Google App Engine and have tried everything but keep getting the following error:
2015-08-19 19:22:08,006 ERROR appcfg.py:2438 An error occurred processing file '':
HTTP Error 403: Forbidden Unexpected HTTP status 403. Aborting.
Error 403: --- begin server output ---
You do not have permission to modify this app (app_id=u'helloworld').
--- end server output ---
If deploy fails you might need to 'rollback' manually.
The "Make Symlinks..." menu option can help with command-line work.
*** appcfg.py has finished with exit code 1 ***
Here is the code from helloworld.py:
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, Udacity!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
And here is my code from the app.yaml file:
application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
Is there a problem with permissions i.e. Google App's or my laptop's settings? I have tried everything that's out there on stackoverflow so any new suggestions will be much appreciated!!
In my case, I got refused because the appcfg save my ouauth2 token in the file ~/.appcfg_oauth2_tokens, which happen to be another account of appengine . Simply remove the file and try again. It should work. This is in Mac, I am not sure about windows though.
Ok there is a MUCH easier way to do this now.
If you are getting this message "You do not have permission to modify this app"
but your id is correct within app.YAML do the following:
Bring up the Google App Engine Launcher on your desktop
Click on the control tab on the top left --> "Clear Deployment Credentials"
Thats it!!!
The application name in app.yaml is sort of like a domain name. Once someone has reserved it, no one else can use it. You need to go here, and then select "Create a project..." from the dropdown at the top of the screen. In the popup, it will suggest a project id, or you can select your own. Many project id's are taken so you will need to specify something unusual to get something that is not taken.
You then put this project id in your app.yaml in the application line. You should then be able to upload your project.
Make sure you have created a project in GAE which project ID is exactly same to your configuration in app.yaml
workflow:
Create a project in GAE and set a name
At the same window you can edit the project ID
copy the project ID and paste it when you create a new application in GAE launcher (or edit your app.yaml to set the value of application)
deploy it and type {project-id}.appspot.com in your browser\ Good luck!
App ID ( 'application:' ) in app.yaml mentioned is 'helloworld' which seems to be default for hello world app. Create a new app using: https://console.cloud.google.com/home/dashboard and use the new app ID in app.yaml.
Please have a look at: Application for gae does not deploy that has answer to similar question for Linux platform, where we need to delete : ~/.appcfg_oauth2_tokens* to resolve the permission error.
Related
I have the following code which works successfully when I deploy it on App Engine. Except I want to run it with a cron.
import pandas as pd
import requests
from flask import Flask
app = Flask(__name__)
#app.route('/')
def sfLibraries():
return 'Success'
if __name__ == '__main__':
app.run(host='127.0.0.1', port=8080, debug=True)
cron.yaml
cron:
- description: "SF Loader"
url: /task/loader
schedule: every 1 hours
app.yaml
runtime: python38
handlers:
- url: /task/loader
script: auto
I know that if I change #app.route('/') to #app.route('/task/loader') that the cron will work successfully, yet I lose the capability to go to the site when I first deploy it and see success.
gcloud app browse
Did not detect your browser. Go to this link to view your app:
https://<<<my_synapse>>>.uc.r.appspot.com
https://<<<my_synapse>>>.uc.r.appspot.com:
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
How can I have it both ways -both able to go to the site via gcloud app browse and see success as well as run the cron successfully?
I mentioned WSGI Handler because I found this pertinent post but not sure how WSGI Handler might help or improve from what Flask is doing Setting up cron job in google app engine python
Create two different routes to accomplish what you need. The functions must have a different name in this case.
#app.route('/')
def sfLibraries():
return 'Success'
#app.route('/task/loader')
def sfLibrariesSecond():
return 'Success'
Assign different actions for each one.
They could also both do the exact same thing. If that was the case, then assign two routes to the same function.
#app.route('/')
#app.route('/task/loader')
def sfLibraries():
return 'Success'
I am having a problem that when I get user location by using http://freegeoip.net/json, it seems to get the location from where the Heroku server is located.
I used Flask to make the web app.
I uploaded the web app through Heroku.
Per the api docs here you need to pass the ip of the user like 'http://freegeoip.net/json/%s' % request.remote_addr. Otherwise it will return the location of the requester, which in your case is your heroku server.
I am trying to use google app engine to create my own proxy for internet browsing, as my college blocks almost everything. Every time I try I end up with terminal sitting there for hours not doing anything and lagging my computer. If anyone can help me with this it would be greatly appreciated. Is it the fact that when it asks for a python command to launch I skip it? Please help and thanks in advance.
Terminal is doing this:
gcloud app deploy
You are about to deploy the following services:
- test-proxy-151010/default/20161129t214424 (from [/Users/OliverPinel/app.yaml])
Deploying to URL: [https://test-proxy-151010.appspot.com]
Do you want to continue (Y/n)? y
If this is your first deployment, this may take a while...failed.
WARNING: We couldn't validate that your project is ready to deploy to App Engine Flexible Environment. If deployment fails, please check the following message and try again:
Server responded with code [400]:
Bad Request Unexpected HTTP status 400.
Failed Project Preparation (app_id='s~test-proxy-151010'). Out of retries. Last error: Temporary error occurred while verifying project: TEMPORARY_ERROR: Operation does not satisfy the following requirements: billing-enabled {Billing must be enabled for activation of service '' in project 'test-proxy-151010' to proceed., https://console.developers.google.com/project/test-proxy-151010/settings}
com.google.api.management.server.common.exceptions.ServiceManagementNonRetriableStorageException: Operation does not satisfy the following requirements: billing-enabled {Billing must be enabled for activation of service '' in project 'test-proxy-151010' to proceed.,
h ttps://console.developers.google.com/project/test-proxy-151010/settings}
at com.google.api.management.server.integrations.usage.requirements.RequirementChecker.lambda$checkAllAsync$3(RequirementChecker.java:158)
at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:246)
at com.google.common.util.concurrent.AbstractTransformFuture$TransformFuture.doTransform(AbstractTransformFuture.java:236)
at com.google.common.util.concurrent.AbstractTransformFuture.run(AbstractTransformFuture.java:137)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:439)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:903)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:814)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:656)
at com.google.common.util.concurrent.CollectionFuture$CollectionFutureRunningState.handleAllCompleted(CollectionFuture.java:81)
at com.google.common.util.concurrent.AggregateFuture$RunningState.processCompleted(AggregateFuture.java:245)
at com.google.common.util.concurrent.AggregateFuture$RunningState.decrementCountAndMaybeComplete(AggregateFuture.java:232)
at com.google.common.util.concurrent.AggregateFuture$RunningState.access$300(AggregateFuture.java:78)
at com.google.common.util.concurrent.AggregateFuture$RunningState$1.run(AggregateFuture.java:135)
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:439)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:903)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:814)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:656)
at com.google.net.rpc3.client.AbstractRpcFuture.success(AbstractRpcFuture.java:114)
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher$1.runInContext(RpcStub.java:847)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:457)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:276)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:316)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:308)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:454)
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher.runCallback(RpcStub.java:885)
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher.rpcFinished(RpcStub.java:895)
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher.success(RpcStub.java:874)
at com.google.net.rpc3.impl.client.RpcClientInternalContext.runCallbacks(RpcClientInternalContext.java:1243)
at com.google.net.rpc3.impl.client.RpcClientInternalContext.finishRpcAndNotifyApp(RpcClientInternalContext.java:1140)
at com.google.net.rpc3.client.loadbalancer.ReplicatedRpcChannel$InterceptedCallback.finishRpc(ReplicatedRpcChannel.java:1087)
at com.google.net.rpc3.client.loadbalancer.ReplicatedRpcChannel$InterceptedCallback.rpcFinished(ReplicatedRpcChannel.java:949)
at com.google.net.rpc3.client.loadbalancer.ReplicatedRpcChannel$InterceptedCallback.success(ReplicatedRpcChannel.java:911)
at com.google.net.rpc3.impl.client.RpcClientInternalContext.runCallbacks(RpcClientInternalContext.java:1243)
at com.google.net.rpc3.impl.client.RpcClientInternalContext.finishRpcAndNotifyApp(RpcClientInternalContext.java:1140)
at com.google.net.rpc3.impl.client.RpcNetChannel.afterFinishingActiveRpc(RpcNetChannel.java:1676)
at com.google.net.rpc3.impl.client.RpcNetChannel.finishRpc(RpcNetChannel.java:1491)
at com.google.net.rpc3.impl.client.RpcNetChannel.handleResponse(RpcNetChannel.java:3306)
at com.google.net.rpc3.impl.client.RpcNetChannel.messageReceived(RpcNetChannel.java:3045)
at com.google.net.rpc3.impl.client.RpcNetChannel.access$2900(RpcNetChannel.java:181)
at com.google.net.rpc3.impl.client.RpcNetChannel$TransportCallback.receivedMessage(RpcNetChannel.java:4254)
at com.google.net.rpc3.impl.client.RpcChannelTransportData$TransportCallback.receivedMessage(RpcChannelTransportData.java:688)
at com.google.net.rpc3.impl.wire.RpcBaseTransport.receivedMessage(RpcBaseTransport.java:463)
at com.google.net.rpc3.impl.wire.RpcClientTcpTransport.parseOneMessage(RpcClientTcpTransport.java:889)
at com.google.net.rpc3.impl.wire.RpcClientTcpTransport.parseMessages(RpcClientTcpTransport.java:766)
at com.google.net.rpc3.impl.wire.RpcClientTcpTransport.access$400(RpcClientTcpTransport.java:47)
at com.google.net.rpc3.impl.wire.RpcClientTcpTransport$2.dataReceived(RpcClientTcpTransport.java:366)
at com.google.net.async3.SocketConnection.handleNetworkReadEvent(SocketConnection.java:1104)
at com.google.net.async3.SocketConnection.access$800(SocketConnection.java:47)
at com.google.net.async3.SocketConnection$NetworkReadHandlerImpl.run(SocketConnection.java:1125)
at com.google.net.eventmanager.AbstractFutureTask$Sync.innerRun(AbstractFutureTask.java:260)
at com.google.net.eventmanager.AbstractFutureTask.run(AbstractFutureTask.java:121)
at com.google.net.eventmanager.EventManagerImpl.runTask(EventManagerImpl.java:594)
at com.google.net.eventmanager.EventManagerImpl.internalRunWorkerLoop(EventManagerImpl.java:1012)
at com.google.net.eventmanager.EventManagerImpl.runWorkerLoop(EventManagerImpl.java:892)
at com.google.net.eventmanager.WorkerThreadInfo.runWorkerLoop(WorkerThreadInfo.java:161)
at com.google.net.eventmanager.EventManagerImpl$WorkerThread.run(EventManagerImpl.java:1877)
Suppressed: java.util.concurrent.ExecutionException:
Beginning deployment of service [default]...
WARNING: Deployment of App Engine Flexible Environment apps is currently in Beta
WARNING: Could not generate [source-context.json]: Could not list remote URLs from source directory: /Users/OliverPinel
Building and pushing image for service [default]
(then it does nothing)
I am following this web.py Hello World example:
https://library.linode.com/web-servers/nginx/python-uwsgi/ubuntu-12.04-precise-pangolin#sph_more-information
Now I get the "Hello World!" example from above page perfectly to run in my Browser, but when I want to change the application to my need, e.g. make a fully AJAX app out of it like this:
urls = ('/(.*)', 'Index')
application = web.application(urls, globals())
web.config.debug = True
class Index:
def POST(self):
content = web.input(_method='post')
return 'Ajax Test Data'
if __name__ == '__main__':application.run()
I get the following error (even if I make minor changes to the "application" function from Linode)
uWSGI Error
Python application not found
How can I get this to work with my own code?
I uninstalled the Debian packages and installed the pip package with build-in Python. I also had to clean up / unify my .ini and -xml configuration files.
I then started my app with
uwsgi -s /tmp/uwsgi.sock -w app
The biggest help came from this document
However, I encountered a web module not found error, so I rolled back to the Linode example and am currently fiddling around with it, still trying to get my app called from inside the application wrapper.
Hi Look at this stackoverflow post:uwsgi error python application not found
You need to kill the old uWSGI process, which is searching for the old instance of the app, which no longer exists because you changed it.
Instead of running the app with if __name__ == '__main__':application.run(), you need to "export" WSGI application to uWSGI. By default uWSGI looks for a WSGI callable named application, but the application you have is not a WSGI callable. So remove if __name__ == '__main__':application.run() and replace application = web.application(urls, globals()) with application = web.application(urls, globals()).wsgifunc().
I'm using Python 2.7 and Google App engine. I've written a page that redirects a user to a form after Oauth has completed. This works perfectly on localhost, but it fails when I deploy to the app engine. What am I doing wrong?
The error message I get is "404. That’s an error. The requested URL /form was not found on this server. That’s all we know."
The server logs don't show my /form request at all.
Relevant snippets follow:
1.app.yaml
handlers:
- url: .*
script: public.main.app
builtins:
- remote_api: on
- admin_redirect: on
2.main.py
app = webapp2.WSGIApplication([
('/form?$', content.Home),
('/oauthcallback?$', content.CallbackHandler),],
debug=True)
3.content.py fxn for /oauthcallback
....
http = credentials.authorize(http)
self.redirect('/form')
Hooray!
Thanks guys for all your help.
#Dave Smith, that syntax: '/form?$' is perfectly alright.
It turns out that '/form' is reserved by the GAE. I renamed my entry and now it works perfectly.
See: https://developers.google.com/appengine/docs/python/config/appconfig#Reserved_URLs