Flask download box - html

I'm trying to make a button that will show the "Save as" download box. The images that I want to offer for download are not in the static folder, nor they will be. Using flask.send_file works by opening the file in the browser.
How can I use send.file in order to bring the download box up, without submitting the page (without changing the current page)?

Look into the as_attachment option in send_file:
http://flask.pocoo.org/docs/api/#flask.send_file
Here's a somewhat related question:
Content-Disposition:What are the differences between "inline" and "attachment"?

Related

html changes won't show up in browser

I'm working on an assignment for a class where our teacher has given us a webpage built out with html and css. We are eventually supposed to create some animations with gsap, but first need to make our own edits to the webpage itself. I am using vscode and when I edit any of the html, the changes show up in my index.html, but not in the browser. Any idea why this is?
try to right click your browser and check in the sources to make sure it really saved your changes.
Try to use live server on VS Code and then whenever you save it will show up on the page.
-> https://techstacker.com/local-live-server-vscode/
Make sure you save the file and reload the page in the browser

how do I search within a CSS file for specific class in Visual Studio Code?

I am using a bootstrap template for a webpage. I want to customise certain parts of it, but I am struggling to find the CSS rules that relate to the HTML classes because the .css file is so large!
All I can find when searching the web for a solution is ways to search for files rather than within them. It looks as if there was an extension that may have worked, but it doesn't seem to exist any longer.
any help would be hugely appreciated.
You can search over files in VS Code using CTRL/SHIFT/F, more info here
This is from the website:
VS Code allows you to quickly search over all files in the currently opened folder. Press Ctrl+Shift+F and enter your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location. Expand a file to see a preview of all of the hits within that file. Then single-click on one of the hits to view it in the editor.
The simplest way to "find the CSS rules that relate to the HTML classes" is still to open your template/website in a browser -> right click the page and "Inspect Element" -> Find the HTML you need to inspect -> You'll have all the CSS classes and rules involved into styling it ...in the sub-tab "Styles".
simple just "ctrl+f" and type whatever you want to search inside text box show on top right corner.

Save as a blank html page instead of content

I am using asp.net web form and the content is displayed let just say in the about-us.aspx.
I know it is impossible to disable Save As option in the browser file menus, but is it possible to have users saving it as a blank HTML page instead of the content?
Even if you could disable the "save as" feature, which... no, you can't. But say for an instant you could. Anyone who wanted (a copy of your webpage) could just take a screen shot and print that. Or, they could open the source code and copy/save that. Saving the file isn't the only way that they can grab your content.
Is there a reason that you don't want them to copy it?
Are you trying to prevent people (in general) from seeing the page?
If there is some other consideration, please leave a comment so we can expand on this.

html dynamic change - how view changed contents?

Javascript run at page opening or later by user action like clicking a button with javascript attached, can alter the page contents and for instance change the layout in the browser.
Using right-click "View Source" shows the original content, not the changed one.
But how/from where can one retrieve the new, changed page contents?
You could use Firebug to see the live contents of the DOM, or you could use Web Developer's view generated source feature.

How can I get rid of the text field next to the “Choose file” button in HTML file upload fields, like GMail does?

Hai,
I have one file upload form in an HTML file. The code is like:
<form>
Select File:<input type="file">
</form>
How can I have only one button (or a link) to upload a file, without having this normal textfield and a browse button? GMail achieves this, but I don’t know how.
How about this http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom
There is a Yahoo User Interface uploader, see http://developer.yahoo.com/yui/uploader/
It requires flash on the browser, though.
JQuery UI also has a customized file uploader: http://wiki.jqueryui.com/w/page/12137894/FileUploader
That's going to involve JavaScript.
Simple. Here is how it goes. First you create a dummy button element or an anchor element. Set its z-index to 1. Place the file upload (<input type='file' >) over the aforementioned anchor or button element(dummy) and set opacity filters for the file upload to zero and z-index to be 2. Now it will appear as though ur link or button or image is being clicked. Whereas the file upload layer on top is the one that is being clicked hence you will get your File upload dialog. (Positioning the file upload element can be done with css easily.)
If you are using jQuery, have a look at this plugin - https://github.com/ajaxray/bootstrap-file-field
This tiny plugin will display the file input field as a bootstrap button (no text field), similar in all browser and will show selected file names (or selection errors) beautifully. Check their live demo.
Additionally you can set various restrictions using simple data-attributes or JS settings. e,g, data-file-types="image/jpeg,image/png" will restrict selecting file types except jpg and png images.
If you want to get rid of the field next to the “Choose file” button, you’ll pretty much have to code your own file upload field using the JavaScript File API, or (if you need to cater for older browsers that don’t support it) a browser plug-in like Flash.
Web browsers generally decide how they display HTML form controls. This is actually quite good, as it means the fields look the same on different websites, which means users can be confident that they know what the controls do.