google-app-engine


can not figure out relation between yaml and main page handler in google app engine


I've have search a lot in google and stackoverflow but can't figure out qhy my code is not working,
app.yaml file follows:
application: morgan629200774
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /.*
script: main.app
- url: /unit1/
script: unit1.app
- url: /unit2/
script: unit2.app
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
libraries:
- name: webapp2
version: "2.5.2"
and here is my code:
import webapp2
form = """
<form method="post">
Enter some text to ROT13
<br>
<br>
<div><textarea name="content" rows="7" cols="50"></textarea></div>
<input type="submit" value="submit">
<br>
<br>
</form>
"""
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.out.write("main page")
class unit1(webapp2.RequestHandler):
def get(self):
self.response.out.write("hello world")
class unit2(webapp2.RequestHandler):
def get(self):
self.response.out.write(form)
self.response.out.write("hello world")
def post(self):
rot13=''
text=self.request.get('content')
rot13=text.encode('rot13')
self.response.out.write(rot13)
app = webapp2.WSGIApplication([
('/.*', MainPage),
('/unit1/', unit1),
('/unit2/', unit2)
], debug=True)
Can someone tell me what am I doing wrong??
Thanks
You haven't got (and don't need) a unit1.app or unit2.app, so I don't know why you've referenced them in app.yaml. As you can see from the Python code, there is one object called app, which contains the routes for the whole application. I presume (although you don't state) that the Python file is called "main.py". which is why the app.yaml refers to main.app - ie the app object in the main module.
The purpose of the URLs in app.yaml is simply to hand off to the Python code. So, you only need a single handler: the first one. Delete the other two handlers. That captures everything under / and passes it to main.app. In that file, the first route defined at the bottom should be:
('/', MainPage)
because you don't want to capture everything in that route, only the specific root URL.

Related Links

If I use ObjectifyFilter I get error
Is there an API for creating google cloud platform credentials?
How to make programmatic access to an appengine application that is secure and authenticated
What App Engine datastore caching strategy will give complete cache consistency?
Google App Engine : High CPU Utilization
appengine cloud storage compile error in demo project
Issue with using the Google Datastore query console
How can I run `gcloud preview app setup-managed-vms` without this error?
Appengine unit test fail with Objectify - No Class registered
What is the name of the database or table?
Google Apps Domain Authentication with Google App Engine - Too many redirects
can I combine NDB and mysqldb in one app on google cloud platform
Logging in a Google Cloud Endpoint
Appengine Maven Plugin - Endpoints Goal - Enable filtering on .discovery files
authentication request once for both side
How do I remove my reported issue from google code bug tracking?

Categories

HOME
cygwin
turing-machines
prism
telegram
zend-framework
components
obfuscation
carousel
bing-maps
android-securityexception
emoji
rtf
angular-dart
gource
eip
symbol
powershell-v5.0
mathprog
easyphp
git-extensions
mapstruct
oledb
selinux
interpreter
xcode-ui-testing
jackson-modules
nstimer
ms-access-2003
apktool
ceylon
paperjs
quantlib
iis-express
testcomplete
alm
gitlab-api
hibernate-validator
hreflang
installshield-le
wurfl
zoomify
node-mssql
loading
azure-arm
portforwarding
logback-groovy
android-exoplayer
ntvs
libgphoto2
convex-optimization
video-conferencing
css-transforms
payload
objectscript
cd-burning
angular2-testing
lrs
greatest-n-per-group
jodd
scaffolding
kiosk
thread-sleep
aspen
highland.js
state-restoration
assertion
ess
poppler
dronekit-android
code-documentation
nodelist
contrast
linkedin-jsapi
cancellation
android-framework
gae-quotas
midlet
cuda-gdb
window-decoration
jsr286
stress
hibernateexception
agility.js
user-tracking
cgbitmapcontextcreate
delimited-text
sifr
django-piston
sifr3
int64
lemmatization
contentpresenter
cardspace

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile