Atm, when trying to access
www.eyalw.com/1keyboard/
you get nothing,
but when accessing
www.eyalw.com/1keyboard
you get the correct page.
this is the current yaml:
application: eyalwcom
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /
static_files: static/index.html
upload: static/index.html
- url: /1keyboard
static_files: static/1keyboard.html
upload: static/1keyboard.html
- url: /
static_dir: static
libraries:
- name: webapp2
version: "2.5.2"
You can put in a regexp to match your url.
I'm not certain I can get the right regexp off the top of my head, I think it would be:
- url: /1keyboard/?
If you would like a trailing slash to always be added you can use a RedirectRoute from webapp2 with strict_slash=True, as described here: http://webapp-improved.appspot.com/api/webapp2_extras/routes.html#webapp2_extras.routes.RedirectRoute1
Instead of adding this to your app.yaml file you would include this where you defined the other routes and linked them to handlers.
Related
I have serverless_common.yml file for all shared things across all my lambdas and I have serverless.yml in my individual service when I try to import package.patterns in to my individual service yml file I get following error when I do sls print
Serverless Error ----------------------------------------
Configuration error:
at 'functions.app.events[0]': unrecognized property 'enabled'
at 'package.patterns[0]': should be string
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.16.1
Framework Version: 2.46.0 (local)
Plugin Version: 5.4.0
SDK Version: 4.2.3
Components Version: 3.12.0
#serverless_common.yml
package:
patterns:
- '!target/**'
- '!tests/**'
- '!test/**'
- '!tools/**'
- '!README.md'
- '!node_modules/.bin/**'
- '!serverless/**'
- '!.*'
#service1/serverless.yml
package:
individually: true
patterns:
- something-specific-to-service1
- ${file(../serverless_common.yml):package.patterns}
functions:
app:
handler: index.handler
name: service1
events:
- schedule: cron(0 09 * * ? *)
enabled: false
serverless_common.yml
/service1
|- package.json
|- index.js
|- serverless.yml
/service2
|- package.json
|- index.js
|- serverless.yml
The errors are warning you that you've got two indentation issues.
The first is in your serverless_common.yml file. The array items should be indented one place further:
#serverless_common.yml
package:
patterns:
- '!target/**'
- '!tests/**'
- '!test/**'
- '!tools/**'
- '!README.md'
- '!node_modules/.bin/**'
- '!serverless/**'
- '!.*'
The second is in your cron expression. The one-line syntax is only if you're not using other arguments. Since you want to pass enabled: false, you'll need to use the multiline syntax:
#service1/serverless.yml
functions:
app:
handler: index.handler
name: service1
events:
- schedule:
rate: cron(0 09 * * ? *)
enabled: false
Unfortunately, the syntax you've chosen won't merge the two arrays. You'll have to reference each item in your array individually, or rewrite your serverless.yml into a serverless.js file, which allows you to be more programmatic.
package:
individually: true
patterns:
- something-specific-to-service1
- ${file(../serverless_common.yml):package.patterns.foo}
- ${file(../serverless_common.yml):package.patterns.bar}
# ... etc
I need to forward URLs, but the handlers in my app.yaml file are not accepting any configuration:
handlers:
- url: "/dashboard/([a-z])"
script: /admin/index.php?page=\1&token=xxx
- url: "/dashboard/login"
script: /admin/login.php?token=xxx
It only works if you access the full URL.
What's wrong?
I am using Google Cloud Platform's PHP based static server. My public folder contains one landing page and and a web-app.
The landing page just is a static html file with few css and image files which resides on root.
The web-app is made of React, it's index.html resides inside the folder named app
I have configured my react app to use BrowserRouter.
The web-app returns 404 error when I refresh any page inside the app.
How to configure app.yaml to solve this. My current configuration is below:
runtime: php55
api_version: 1
threadsafe: true
skip_files:
- src/
- node_modules/
- ^(.*/)?app\.yaml
- ^(.*/)?gitlab\.yml
- ^(.*/)?app\.yaml
- ^package\.json
- ^package-lock\.json
- ^README\.md
- ^webpack.config\.js
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
handlers:
- url: /
static_files: public/index.html
upload: public/index.html
secure: always
- url: /app/(.*\.(html|js|css))$
static_files: public/app/\1
upload: public/app/.*\.(html|js|css)$
secure: always
- url: /(.*)
static_files: public/\1
upload: public/(.*)
secure: always
I want to achieve something like nginx server's try_files option.
So I am getting this when I try to deploy my app. Here are the files that make up my app:
main.py:
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write("<h1>Duracron!</h1>")
class EventHandler(webapp2.RequestHandler):
def get(self):
self.response.write("<h1>Duracsron!</h1>")
app = webapp2.WSGIApplication([
('/', MainHandler),
('/event/.*', EventHandler),
], debug=True)
app.yaml:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /.*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
- name: ssl
version: latest
cron.yaml:
cron:
- description: test task
url: /events/test
schedule: every 1 minutes
I can't seem to find out what's going wrong. From my understanding, the cron.yaml will make a request to the /events/test and app.yaml will redirect it to main.app and main.app routes it to EventsHandler(). What am I missing?
It looks like a typo in the word event which doesn't match events and that may be the cause of the problem. Try changing ('/event/.*', EventHandler), to ('/events/.*', EventHandler), so that it matches your cron.yaml
I was wondering how you can configure your app to restrict certain endpoints to logged in users or even admin users.
Here is my app.yaml
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
- url: /admin/.*
script: main.app
login: admin
However this doesn't work. When visiting any endpoint beginning with /admin/ I can simply access the url without logging in. Is there any configuration setting that I'm missing?