I have a strange problem with css file in google app engine.
If i use
handlers:
- url: /cms/.* script: cms.py
- url: /
script: main.py
- url: /stylesheets
static_dir: stylesheets
in my app.yaml file for http://localhost:8080/ it works fine.
But when i redirect it to another handler in main.py It gives such an error
Not found error: /login did not match any patterns in application configuration.
When I use this
handlers:
- url: /cms/.* script: cms.py
- url: .*
script: main.py
- url: /stylesheets
static_dir: stylesheets
whole logic works just fine ( no error occurs wherever I roam in the application) but no sign of css this time.
I hope you can help me.
Thanks in advance..
Try with this:
- url: /stylesheets
static_dir: stylesheets
- url: /cms/.*
script: cms.py
- url: /.*
script: main.py
Your first solution does not work with /login because using / you are getting just the root
Your second solution does not work because stylesheets cames after the catch all pattern .*
Related
all I just deploy my laravel project on google cloud but the CSS and JS are not working.
Here's my app.yml
runtime: php73
handlers:
- url: /public/assets
static_dir: assets
env_variables:
## Put production environment variables here.
APP_KEY: Already Get this from .env
APP_STORAGE: /tmp
VIEW_COMPILED_PATH: /tmp
SESSION_DRIVER: cookie
Any one of you can help me to make it work
Here's the one link from my head.php file
<link rel="stylesheet" href="{{ asset('assets') }}/css/bootstrap.css">
You may have these backwards. Instead of:
handlers:
- url: /public/assets
static_dir: assets
Shouldn't it be:
handlers:
- url: /assets
static_dir: public/assets
because the url you are hitting doesn't have /public. I would need to see your directory tree to say for sure.
I'm trying to test Laravel 5.3 application. To bootstrap an application with testing config I have added index-testing.php entry point.
I have my codeception acceptance test config like this:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://nginx/index-testing.php'
host: 'selenium'
browser: 'chrome'
- \Helper\Acceptance_selenium
And here is a piece of output of the test scenario:
Scenario --
I am on page "/"
[GET] http://nginx/index-testing.php/
I click ".apply-button"
So instead of http://nginx/index-testing.php it actually goes to http://nginx/index-testing.php/ which of course results in 404
How to I remove this trailing slash?
I found the answer!
In a test I was getting home page like this:
$I->amOnPage('/');
When I changed to this:
$I->amOnPage('');
No more trailing slash present.
I try connect Vue.js with Symfony 3, but have no idea how to create proper route configuration for it.
Project tree looks like that:
Project root
- app/
- Resources/
- views/
- default/
- web/
- assets/
- static/
index.html // here Vue is included
From Symfony I provide some REST API, the routes to it are prefixed by /api/. And I have some routes in Vue SPA.
The problem is if I press F5 in browser on any Vue route, which of course is not included in my routing.yml, browser returns 404 error from Symfony.
One half-working decision is when I put content of index.html to Resourses/views/default/twig with such a route:
fallback_for_vue:
path: /{req}
defaults: { _controller: 'AppBundle:Default:index' }
requirements:
req: ".+"
,taken from another question, but this is not actually what I need, because I don't want my frontend programmer to go somewhere except web/ folder.
So which configuration of Symfony routes I should use?
You need a wildcard address to point to your Vue.js application. Otherwise when you reload you send a request to Symfony, and it doesn't know hoy to handle it.
vuejs_wildcard_route:
defaults: { _controller: AppBundle:YourController:yourAction }
path: /vuejsappbasepath/{whatever}
requirements:
whatever: .*
defaults:
whatever: null
I have this setup working with a reactjs app and is working perfectly.
YourController is the controller that contains yourAction, the one that loads the template with the Vue.js panel.
Kindly see this link: http://webdeveloperim.appspot.com/
I have try lots of way to work with css but still not working.
My app.yaml code:
application: webdeveloperim
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))
- url: /robots.txt
static_files: robots.txt
upload: robots.txt
- url: /stylesheets
static_dir: stylesheets
secure: always
- url: .*
script: main.py
Index.html File code:
<!-- ==============================================
CSS
=============================================== -->
<link rel="stylesheet" href="stylesheets/bootstrap.min.css">
<link rel="stylesheet" href="stylesheets/font-awesome.css">
<link rel="stylesheet" href="stylesheets/flexslider.css">
<link rel="stylesheet" href="stylesheets/designr-theme-cyan.css">
<link rel="stylesheet" href="stylesheets/fix.css">
Please give me a right solution. thanks.....
Cut down the complexity of your handlers, make it a running app that you understand how it works and later experiment how your app.yaml can become better, match specific extensions etc.
I don't know how your dir structure looks so I'll prompt you to a simple config with static files that can be js, css, etc. I ll keep it simple.
Sample app.yaml
This block will make a single file robots.txt under the / of your project match any request of http://myapp.appspot.com/robots.txt
- url: /robots.txt
static_files: robots.txt
upload: robots.txt
This block will match any filename requested under /js/ of your project. Example http://myapp.appspot.com/js/jquery.js
- url: /js
static_dir: js
Now I hope you get the point on how you can configure your app.
This is a complete example with css, js, images, robots.txt. Not the best approach but is fairly simple.
- url: /robots.txt
static_files: robots.txt
upload: robots.txt
- url: /js
static_dir: js
- url: /images
static_dir: images
- url: /css
static_dir: css
- url: /.*
script: main.app
Now the dir structure for the above would look like:
/
|-robots.txt
|-js/
|-css/
|-images/
|-main.py
I hope it helps.
I'm working on a webpage in Go. The Go code uses "html/template" to parse HTML. I would like to use CSS in the project. Everything is working well when I use internal CSS code, but when I would like to change to external it dosen't work. It looks like it can't access to the .css file.
Here is my app.yaml configuration:
application: makerboardstest
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
- url: /stylesheets
static_dir: stylesheets
- url: /images
static_dir: images
Here is how I would like to access to the .css from the html:
<head>
<link href="/stylesheets/main.css" media="screen" rel="Stylesheet" type="text/css" />
</head>
I also have problems with (static) images. I would like to access to the image with this html code:
<img src="/images/img1.jpg" />
What can be the problem?
(I'm testing it on my PC, Win 7)
The handlers are checked in order, and your first handler matches everything; move your static handlers up above it. In other words, when your browser makes a request for /stylesheets/main.css, it matches the /.* pattern of your first handler and asks go to serve it rather than trying the static dir. If you flip the order of the handlers, it will match /stylesheets first and serve it from the static dir.
i.e.:
handlers:
- url: /stylesheets
static_dir: stylesheets
- url: /images
static_dir: images
- url: /.*
script: _go_app