I am trying to follow all the steps as according to this blog here to host a static website using google app engine. The app.yaml file looks like this:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: website/index.html
upload: website/index.html
- url: /
static_dir: website
Say my project ID is abcd-123. When I go to abcd-123.appspot.com, it's giving the 404 error. (Also, I am using the same folder they've provided for hosting). Please suggest what am I doing wrong?
Make sure that you have a website folder, and inside of it, you have index.html file, along with a self created app.yaml file. Also make sure that you mention your project id while running the set project command and not project name!
Related
I was able to preview the HTML page on cloud shell and it shows everything correctly. when i deploy the app using "gcloud app deploy", the display is not showing the same page display as the preview page. for the deployment view, a specific CSS file data was pulled. while the preview page pulled from another CSS file. I have 2 different CSS files. app.yaml appended here. please advise.
{
runtime: python37
runtime_config:
entrypoint: "gunicorn -b:$PORT main:app"
env: flex
python_version: 3
handlers:
-
static_dir: images
url: /images
-
static_dir: static/css
url: /css
-
static_dir: templates/css
url: /css
-
script: auto
url: /.*
Considering your app.yaml, indeed, it seems that your CSS files are not being ready while your application is deployed and run.
For this reason, I would recommend you to take a look at the articles CSS and multiple HTML files in App Engine and Loading Images and CSS in AppEngine, where you can find more information and assistance on configuring your App Engine to read and use the CSS file during the deployment.
Let me know if the information helped you!
I am currently trying to setup a gcloud appspot domain. I am consistently getting this error when I attempt to open up my appspot project on the browser:
Error: Not Found
The requested URL / was not found on this server.
Here is my code. How can I fix this?
app.yaml -
runtime: go
api_version: go1
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
main.go -
package app
func main() {}
The reason of the HTTP 404 error is that the files your handlers are looking for are not there, or are not in the correct directory. Meaning there has to be an index.html in the directory 'www', which must be located in the root directory of your app.yaml deployment.
For example if your app.yaml and main.go files are in the directory /myapp, the full path of the file index.html has to be /myapp/www/index.html.
just to add...
I was running the Google Tutorial and missed the file structure requirement. My index.html file was not in the www directory. Once I created the www directory and moved the index.html file there the tutorial executed correctly.
The final structure was:
app.yaml
www
index.html
As was pointed out in the above answer, its likely your directory/file structure may be the issue.
On my computer, I access my test webpage on URL http://127.0.0.1:4000. On server, it will be on GitHub pages, that means https://username.github.io/repo-name/.
In the _config.yml I see following relevant settings:
# Uncomment if you are planning to run the blog in a subdirectory
# Note - if you enable this, and attempt to view your site locally you have to use the baseurl in your local path.
# Example, you must use http://localhost:4000/path/to/blog
#baseurl: /path/to/blog
baseurl:
# The URL of your actual domain. This will be used to make absolute links in the RSS feed.
url: http://yourdomain.com/
So for GitHub server I need it to be:
baseurl: /repo-name/
url: https://username.github.io/
But on localhost, it must be:
baseurl:
url: http://127.0.0.1:4000
These settings are necessary because without them, I will get 404 errors for resources that are using relative paths:
<script src="js/ghapi.js"></script>
"NetworkError: 404 Not Found - http://127.0.0.1:4000/download/js/ghapi.js"
The path should be http://127.0.0.1:4000/js/ghapi.js but since the page was /download it was added to relative URL of the script file.
I need to deal with this issue, how do I do that?
The best solution was to have two config files. The additional one, debug.yml, overrides some settings from the basic one. Both setting files can be loaded using this command:
jekyll serve --config _config.yml,debug.yml
The debug file can contain:
name: MySite [DEBUG MODE]
debug: true
url: http://127.0.0.1:4000
The advantage here is that no setting files need to be changed, you just use different command to run jekyll.
For me the best option is having in config.yml the baseurl used in Github pages and when you launch your site locally, override this value with an empty one:
bundle exec jekyll serve --baseurl=
That way, the site will work on localhost and in ghpages.
you can add a branch and change url line in config.yml
url: http://127.0.0.1:4000
I have a website with an index.html as homepage that works fine, but i want to create a website structure with subfolders, so i create a folder named "team", inside team i put an index.html file with the team information. When i load www.mysite.com/team/index.html it works fine, but if i load www.mysite.com/team i get an 404 error.
how i do fix this for automatically load the index.html inside the subfolder??
I am using google app engine as a server, i upload files with google app engine launcher and using some phyton files.
In you app.yaml, define your static file handlers like this:
…
handlers:
- url: /static
static_dir: static
- url: /(.*?)/?
static_files: \1/index.html
upload: (.*?)/index.html
…
Note that because you define your website structure like this, you won't be able to access any other file except the index.html files. For example, if you go to /images/logo.png, App Engine would try to serve that from the static file images/logo.png/index.html.
To fix that problem, you'll need to put all your static files in a different subdirectory (/static in the above example), and serve that as a static_dir. Then you should reference your files from the index.html files as /static/images/logo.png, etc.
UPDATE: I'll paste your app.yaml here because you cannot format it correctly in the comment:
handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css|php|xml))
static_files: \1
upload: (.*\.(gif|png|jpg|ico|js|css|php|xml))
- url: /robots.txt
static_files: robots.txt
upload: robots.txt
- url: /favicon.ico
static_files: favicon.ico
upload: favicon.ico
- url: .*
script: main.py
- url: /static
static_dir: static
- url: /(.*?)/?
static_files: \1/index.html
upload: (.*?)/index.html
Your problem is that the - url: .* directive catches everything so the bottom two handlers are never reached.
Also, you should consider using an application reference in the script instead of the file name. Providing the script file name is deprecated.
I uploaded my client's webpage using google app engine and it is working fine. It is a very simple webpage with 12 static files (.html all of them)
I have to remove the file, but I don't know if this can be done modifying the app.yaml or the main.py
For example: I have www.example.com/page.html, I want www.example.com/page
You can try this on your app.yaml assuming all your html files are in static folder.
handlers:
- url: /(.+)
mime_type: text/html
static_files: static/\1.html
upload: static/(.+)
Meaning it will match all and look up static folder with .html extension
if you want specific files you can do
- url: /(hello|world)
mime_type: text/html
static_files: static/\1.html
upload: static/(.+)
means files hello.html and world.html only, to avoid handling all urls.
If you are looking at removing the file, I do not think you can directly do that via the Administration Console or any utility.
You will need to remove the files from your local project and then upload the same again.