I created the app.yaml and index.py files in a folder.
app.yaml
application: firstpython
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: index.py
index.py
print 'Content-Type: text/plain'
print ''
print 'Hello, World'
When I run the dev_appserver.py folder command, I see the page from my own computer by typing localhost:8080. But computers on the same network another can not reach this page by typing my ip, eg 192.168.1.35:8080.
How can I do that?
Related
I have created folder that is apps, and that having the subfolder that is ae-01-trivial.Added app.yaml to the ae-01-trivial,
Following code are added to the app.yaml:
application: ae-01-trivial
version: 1
runtime: python34
api_version: 1
handlers: -
url: /.*
script: index.py
And also added index.py to the ae-01-trivial, it is having following code:
print 'Content-Type: text/plain'
print ' '
print 'Hello there Chuck' .
So here I have facing the problem is "no such projects are selected".
If you're trying to create a request handler in App Engine, follow this example. Also Google App Engine uses Python 2.7 runtime for Python applications, so 3.4 may not work.
I have tried all the existing resources but to no avail.
here is my app.yaml code:
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
Here is my webapp2 code:
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
All in my hello_world directory. I proceed to add existing application and point to the hello_world directory where helloworld.py (webapp2) script and the app.yaml code are living. I hit run on Google App Engine and it just stays loading, it never completes. Therefore, my http://localhost:8080/ page never loads.
You're missing the application: line in your app.yaml.
You're probably also gonna need to list the 3rd party webapp2 in the libraries section, something like this:
libraries:
- name: webapp2
version: "2.5.2"
I'm trying to get web.py app running on local Google App Engine.
My yaml:
application: appname
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: code.app
My code.py:
import web
urls = (
"/.*", "hello",
)
app = web.application(urls, globals())
class hello:
def GET(self):
return 'Hello, world!'
app = app.gaerun()
When I start the server all I get is a blank page. So what's wrong?
Edit:
python --version
Python 2.7.6
Edit 2:
Error from console:
ImportError: No module named web
What you're trying to do is import an external module, which is not supported by GAE.
What you can do though, is copy web.py into your app directory, and then use it. See "How to include third party Python libraries in Google App Engine".
You can get the source code from here
I have been trying to upload python Google app engine folder using windows command prompt. I have the app.yaml as well as a python file in the folder. But when I pass the following command in the Command Prompt:
appcfg.py --oauth2 update C:/Path/to/the/folder
I get this error.
appcfg.py: error: Directory does not contain an Project.yaml configuration file.
Where am I wrong and how should I proceed?
This is my app.yaml file:
application: myappid
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: sampleapp.app
libraries:
- name: lxml
version: "latest"
Check your shell syntax. I had this error message also, by not referencing the right project folder. Note the ending slash:
appcfg.py --oauth2 update C:/Path/to/the/folder/
Hi I'm trying to get my Google App Engine application running on local host but I'm getting issues when I try to run it.
This is the code I'm tryng to run:
# helloworld.py
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
#"Test" text is not displayed
self.response.write("Test")
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)
#This line prints the content
print "This works fine"
When I run the dev server on localhost I get Code 200 as response but the handler doesn't seems to be executed properly.
Any idea?
Your code looks fine, just make sure your in your app.yaml you have the handlers correct. It should look something like this:
application: helloworld
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: .*
script: helloworld.app
libraries:
- name: webapp2
version: "2.5.2"
If you haven't done it yet, you should also complete the Getting Started tutorial.
I solved this issue. Using webapp2 library I have to add the folowing code to the *.yaml file:
libraries:
- name: webapp2
version: "2.5.2"