When updating my app into GAE by using the following command:
python appcfg.py update /home/tom/workspace/DjangoProject
I got an error message:
mapping values are not allowed here
in "/home/tom/workspace/DjangoProject/app.yaml", line 6, column 9
Here is my yaml:
application:myapp
version:1
runtime:python
api_version:1
handlers:
- url:/
script:home.py
- url:/index\.html
script: home.py
- url: /stylesheets
static_dir: stylesheets
- url: /(.*\.(gif|png|jpg))
static_files: static/\1
upload: static/(.*\.(gif|png|jpg))
- url: /admin/.*
script: admin.py
login: admin
- url: /.*
script: not_found.py
Can anybody help me?
I changed my yaml:
application:myapp
version:1
runtime:python
api_version:1
handlers
- url:/
script:home.py
- url:/index\.html
script:home.py
- url:/stylesheets
static_dir:stylesheets
- url:/(.*\.(gif|png|jpg))
static_files:static/\1
upload:static/(.*\.(gif|png|jpg))
- url:/admin/.*
script:admin.py
login:admin
- url:/.*
script:not_found.py
Now the error meesage is :
google.appengine.api.appinfo_errors.MissingURLMapping: No URLMap entries found in application configuration
After a colon , there has to be space . That's why it was not able to parse your app.yaml.
Try this
application: myapp
version: 1
runtime: python
api_version: 1
handlers:
- url: /
script: home.py
- url: /index\.html
script: home.py
- url: /stylesheets
static_dir: stylesheets
- url: /(.*\.(gif|png|jpg))
static_files: static/\1
upload: static/(.*\.(gif|png|jpg))
- url: /admin/.*
script: admin.py
login: admin
- url: /.*
script: not_found.py
Related
I have come across a problem with the app.yaml setup for the installation of wordpress in GAE following this guide: https://developers.google.com/appengine/articles/wordpress
Using the guide, I copied the app.yaml (I also used the github project: https://github.com/GoogleCloudPlatform/appengine-php-wordpress-starter-project to check that my copy/paste was ok).
Whilst the test using dev_appserver.py works fine, the upload whinges with the message:
03:08 PM Getting current resource limits.
03:08 PM Scanning files on local disk.
03:08 PM Scanned 500 files.
03:08 PM Scanned 1000 files.
Error 400: --- begin server output ---
Error when loading application configuration:
Unable to assign value '__static__/wordpress/.*\.(htm|html|css|js)$' to attribute 'upload':
Value '__static__/wordpress/.*\.(htm|html|css|js)$' for upload does not match expression '^(?:(?!\^).*(?!\$).)$'
--- end server output ---
I am using the PHP SDK v1.8.9. My app.yaml is as follows:
application: blah-de-blah
version: wp
runtime: php
api_version: 1
handlers:
- url: /(.*\.(htm|html|css|js))$
static_files: wordpress/\1
upload: wordpress/.*\.(htm|html|css|js)$
application_readable: true
- url: /wp-content/(.*\.(ico|jpg|png|gif))$
static_files: wordpress/wp-content/\1
upload: wordpress/wp-content/.*\.(ico|jpg|png|gif)$
application_readable: true
- url: /(.*\.(ico|jpg|png|gif))$
static_files: wordpress/\1
upload: wordpress/.*\.(ico|jpg|png|gif)$
- url: /wp-admin/(.+)
script: wordpress/wp-admin/\1
secure: always
- url: /wp-admin/
script: wordpress/wp-admin/index.php
secure: always
- url: /wp-login.php
script: wordpress/wp-login.php
secure: always
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /wp-(.+).php
script: wordpress/wp-\1.php
- url: /(.+)?/?
script: wordpress/index.php
Something is up with the file type selector regex, but I'm not sure how to fix it. Someone came across it here: Google App Engine and Wordpress set up error - Windows 7 professional but it's still not fixed.
Does anyone have any light to shed on the subject?
Ok - I fixed it. The app.yaml needed modifying.
I think the instructions on the guide are a bit misleading - maybe something is out of date?
Here is my fixed app.yaml:
application: pooper-scooper-117
version: wp
runtime: php
api_version: 1
handlers:
- url: /(.*\.(htm$|html$|css$|js$))
static_files: wordpress/\1
upload: wordpress/.*\.(htm$|html$|css$|js$)
application_readable: true
- url: /wp-content/(.*\.(ico$|jpg$|png$|gif$))
static_files: wordpress/wp-content/\1
upload: wordpress/wp-content/.*\.(ico$|jpg$|png$|gif$)
application_readable: true
- url: /(.*\.(ico$|jpg$|png$|gif$))
static_files: wordpress/\1
upload: wordpress/.*\.(ico$|jpg$|png$|gif$)
- url: /wp-admin/(.+)
script: wordpress/wp-admin/\1
secure: always
- url: /wp-admin/
script: wordpress/wp-admin/index.php
secure: always
- url: /wp-login.php
script: wordpress/wp-login.php
secure: always
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /wp-(.+).php
script: wordpress/wp-\1.php
- url: /(.+)?/?
script: wordpress/index.php
you shouldn't have to modify the app.yaml or submit a pull request(unless it's to change the documentation). Instead you need to get the latest version of the appengine SDK for PHP. As of mid January older versions won't work.
Can I use this for uploading HTML pages?
app.yaml contents:
application: visualvidya
version: 1
runtime: python
api_version: 1
handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css))
static_files: \1
upload: (.*\.(gif|png|jpg|ico|js|css))
A minimal handlers section for a static site might look something like this:
handlers:
- url: /
static_files: static/index.html
upload: static/index.html
- url: /
static_dir: static
Every site is different, so as Sean pointed out in the comments, you'll want to consult the documentation.
I'm in trouble. I'm playing now for a long time with receiving email in google apps but in my application Logs only get this:
0.1.0.20 - - [13/Jun/2013:08:42:23 -0700] "POST /_ah/mail/contact#myappid.appspotmail.com HTTP/1.1" 200 0 - - "myappid.appspot.com" ms=69 cpu_ms=0 cpm_usd=0.100008 app_engine_release=1.8.1 instance=00c61b117c2fb913155f167711d12979c818fd
My mail handler script schould be this: mailmain.py
import logging
import webapp2
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.api import mail
class LogSenderHandler(InboundMailHandler):
def receive(self, mail_message):
tobesent = mail_message.subject
logging.info("From: " + mail_message.sender)
logging.info("To:" + mail_message.to)
logging.info("Subject: " + mail_message.subject)
logging.info("Date: " + mail_message.date)
app = webapp2.WSGIApplication([LogSenderHandler.mapping()], debug=True)
and my app.yaml is this:
application: myappid
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /_ah/mail/contact#myappid.appsportmail.com
script: mailmain.py
login: admin
- url: /.*
script: mailmain.py
inbound_services:
- mail
I've tried playing with the script so I have many versions, some ending in this (if this matters) but really nothing works:
def main():
app = webapp2.WSGIApplication([LogSenderHandler.mapping()], debug=True)
run_wsgi_app(application)
if __name__ == "__main__":
main()
I do have a favicon.ico uploaded as well.
Googled the error up for hours and hours and nothing works.
Here on Stackoverflow I've found for similar error message solutions such as correct recieve into receive but this is not the case here. I've copied other solutions as well, also this from GITHUB so I believe this question is not a duplicate.
You mixing up CGI and WSGI. See Python27 getting started.
Docs : https://developers.google.com/appengine/docs/python/gettingstartedpython27/usingwebapp
Yaml update :
application: myappid
version: 1
runtime: python27
api_version: 1
threadsafe: false
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /_ah/mail/contact#myappid.appsportmail.com
script: mailmain.app
login: admin
- url: /.*
script: mailmain.app
inbound_services:
- mail
With WSGI you do not need the run_wsgi_app stuff.
And some background about CGI / WSGI: http://blog.notdot.net/2011/10/Migrating-to-Python-2-7-part-1-Threadsafe
I'm migrating my gae app to python 2.7. This is my new app.yaml:
application: webfaze
version: main
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /mapreduce(/.*)?
script: mapreduce/main.application
- url: /(.*\.(html|css|js|gif|jpg|png|ico|swf))
static_files: static/\1
upload: static/.*
expiration: "1d"
- url: .*
script: main.application
- url: /task/.*
script: main.application
login: admin
But I get this error message:
Error parsing yaml file:
Invalid object:
threadsafe cannot be enabled with CGI handler: mapreduce/main.application
in "webfaze/app.yaml", line 22, column 1
Can you tell me how to resolve the error?
Checking the source code, it looks that you need to define your handlers' path without any slash:
if (handler.script and (handler.script.endswith('.py') or
'/' in handler.script)):
raise appinfo_errors.ThreadsafeWithCgiHandler(
'threadsafe cannot be enabled with CGI handler: %s' %
handler.script)
Move application.py to the root of your project and modify the handler's path accordingly.
Change:
- url: /mapreduce(/.*)?
script: mapreduce/main.application
To:
- url: /mapreduce(/.*)?
script: mapreduce.main.application
You may also need to add an __init__.py to the 'mapreduce' folder if one doesn't exist there already. That will make the python interpret the folder as a module.
I get this strange message error when trying to run an app using dev_appserver.py:
ERROR 2011-04-21 23:03:44,984 dev_appserver_main.py:407] Fatal error when loading
application configuration:
Value 'warmup' for key ??? does not match expression '^(mail|xmpp_message|rest|startup)$'
in "stackprinter/app.yaml", line 53, column 1
I have no idea what may be causing this, I hope someone is able to at least guide me in the right direction!
EDIT: Content of the app.yaml:
application: foo
version: 1b
runtime: python
api_version: 1
builtins:
- datastore_admin: on
inbound_services:
- warmup
handlers:
- url: /test.*
login: admin
script: gaeunit.py
- url: /favicon.ico
static_files: app/static/images/favicon.ico
upload: app/static/images/favicon.ico
- url: /robots.txt
static_files: app/static/docs/robots.txt
upload: app/static/docs/robots.txt
- url: /crossdomain.xml
static_files: app/static/docs/crossdomain.xml
upload: app/static/docs/crossdomain.xml
- url: /sitemap.xml
static_files: app/static/docs/sitemap.xml
upload: app/static/docs/sitemap.xml
- url: /javascripts
static_dir: app/static/javascripts
- url: /stylesheets
static_dir: app/static/stylesheets
- url: /images
static_dir: app/static/images
- url: /docs
static_dir: app/static/docs
- url: /deleted
static_dir: app/static/deleted
- url: /_ah/queue/deferred
script: $PYTHON_LIB/google/appengine/ext/deferred/handler.py
login: admin
- url: /_ereporter
script: $PYTHON_LIB/google/appengine/ext/ereporter/report_generator.py
login: admin
- url: /admin.*
script: application.py
login: admin
- url: /_ah/warmup
script: application.py
login: admin
- url: /.*
script: application.py
Thanks!
Solved!
The problem was that i had an old GAE SDK, Warmup requests were added in the 1.4.0 version.
Cheers