Forums

Static Web Pages

Hi all - I have been playing around with a lot of different things....but needed to use pythonanywhere to host multiple (20 or so) static files.

I have followed the directions on this page: https://help.pythonanywhere.com/pages/hosting-a-static-site/

However ran into the following issues: 1 - URL as '/' and Path as directory to the Pythonanywhere folder that contains all the HTML files (currently 8 or so) Result - pulls the first file only and not the others 2 - URL as '/__<filename>' and Path as directory to individual HTML file....repeat the process for each file Result - pulls the first file only and not the others

So - key question if I have 20-30 html pages that I want to be hosted here on Pythonanywhere (each page with it's own html page) - how would I go about doing it?

Thanks so much! Brian

That sounds strange! Our blog is just a static site (with files generated via a script), and it has:

  • URL set to "/"
  • Directory set to a directory containing static files

This means that when you go to the blog, it loads up the file called index.html from the specified directory, when you go to https://blog.pythonanywhere.com/194/, it loads up the file called index.html from the subdirectory of the specified directory called 194, and so on.

Could you set things up as per your example 1, which is the setup that should work, and then give an example of a URL that does not load and the exact location of the file that you would expect to see at that URL?

Hi Giles - thanks for the note back!

In following the process - I walked through just setting up a Web App to have an empty canvas....set the URL to '/' and then the Directory set to the directory containing the static files (they are actually plotly graphs if that somehow makes a difference - but the files are saved/stored as HTML).....now I did NOT create an index.html - is that my missing step??? So - the directory is just a bunch of html files.

For the example: The url is: robotamp.pythonanywhere.com
In the Static Files settings: URL: / Directory: /home/robotamp/plotly_scripts/html_plotly

Note: On the directory, I wasn't sure whether to have a '/' at the end or not - I tried it both ways - but this morning when I am trying the process with the URL as '/' and the Directory as the file path to the HTML files (both with a '/' and without) - I only get the generic 'Hello World' default. Also - what is interesting is that when I note the directory to one of the specific files - it generates the correct HTML file.....

Thanks so much Giles for looking at it!

Also - note I was planning on hosting the static HTML here....and then embedding that in a blog over on wordpress......just in case there's any tips on that.....I've been experimenting with multiple processes.

FYI - it seems if I add each html individually to a specific url extension it works just fine....I'll use that process for now - not sure why the global indexing isn't working....

Thank you again for everything! I truly LOVE PYTHONANYWHERE - and y'all are AWESOME!!!!

You shouldn't need to add every file individually. Have a look at our help page for debugging issues with static files: https://help.pythonanywhere.com/pages/DebuggingStaticFiles/