Loading html file inside server directory tree into iframe fails - python

I have a local server using Flask web framework running on my machine. What I want is to load an html file, which is stored in a folder inside the app directory tree, into an iframe. The iframe src points to "fld/file.html", so I'd say that the file is inside scope, but so far I haven't been able to get it to load. I keep getting a "Not Found" error.
What am I doing wrong? Is it a security issue? Can I do it using another approach?

Put the HTML file in your static folder: http://flask.pocoo.org/docs/quickstart/#static-files

Related

Download a file to a google driver folder using selenium in heroku

Can i use the url to a google drive folder as a download_path in selenium
for instance like this .Heroku error says file not found
mudopy.download_path(r"https://drive.google.com/drive/folders/1IPNuefeIXXCKm8Xxm3u1ekltxTF3dCT0")
According to the code of mudopy module, it saves the downloaded file into a local directory. So you can later upload that file to a google drive. Not sure if heroku allows to store something locally.
Moreover, the function mudopy.download_path does not download anything yet, but only creates a local file that stores the path to the folder where you want to save the downloaded files. And looks like Heroku does't even permit creating this file.

Problem downloading files in django template

I'm trying to download a file from a local directory in a Django template, but when I click and download it, I get a File Not Found error on my browser. As soon as I click download, the file explorer to choose the folder opens, but when I save the file I get that error. The path to the file I'm sure is right.
index.html
Download
Django doesn't serve static files by itself.
In order to create a file download link, you need to have a Django view that serves the static file. Refer here for more details https://djangoadventures.com/how-to-create-file-download-links-in-django/

deploying webpage to github where html file is in templates folder

I am attempting to deploy a webpage to github pages where the index.html file is not in the root directory, but in the templates folder. As a result, I keep getting a 404 error page whenever I try to access the url. how can I upload a webpage where the html file is not in the root of the project?
GitHub Pages is a fairly limited hosting service, although nice for what it does. Is there a particular reason why you can't simply move index.html to the root directory? I know these things can be a pain, but I believe the parser that GHP uses is pretty strict about this.

Getting Django to run a main.py file

I've written a scientific program in python which outputs a .png and a .pdf
I would like to execute this main.py file from a web interface, with a nice big button saying GO and then display the .png and download a .pdf
I'm using a Django framework to serve the page saying GO. How do i get it to:
run my main.py file?
return the .png file to html template?
download the file which is generated by the main.py script?
Thank you internet
This question is a little broad for a specific answer, but in general, one can:
Have the button access an API which will, on the server, in another thread, your main.py file.
Once the application is finished, move the generated files to a deterministic location that serves static files on your web server.
Provide the user a URL to the newly created file's location.
Have a cron job run to clear out old files in the static directory.

Deploying Django - Most static files are appearing except images

Most of my static files on my newly deployed Django website are working (CSS), but not the images. All the images are broken links for some reason and I cannot figure out why. I am serving my static files via Amazon AWS S3.
I believe all my settings are configured correctly as the collectstatic command works (and the css styling sheets are up on the web). What could be the problem?
It's probably impossible to give an accurate assessment with the limited info on your setup. If your css files are working what folder are they sitting in on your server?
Why not have images folder in the same directory and set that directory to your MEDIA_URL in your settings.py file?
In your browser check your images full path and compare that to your CSS files, where are they pointing, do you have a directory on your server where they are supposed to be? are you receiving an access denied if you try to directly put in that image url into your browser?

Categories