AngularJS - How to list the filenames from a given folder? - javascript

I have this folder/directory 'x' in the public folder of my application.
Now I have path name till the folder i.e., /path/to/dir/x , but I don't know the names of the files in this directory. Now I need to provide URL links to the files in the html a tag's href attribute.
How do I list the name of the files in this directory?

Angular is a client side library. Getting files from file directories is a backend capability.

Related

How can I disable conversion of .json/.webmanifest url into base64 string?

I have a problem that has been bothering me for a while now. I have a vite-react-typescript project in VSCode, with a link in the index.html page to a webmanifest. This is basically a json file with a different extention.
When I build my app, the index.html output file contains the meta tag, however instead of referencing the path of the .webmanifest file, it has converted the entire file into base64. Because of this some browsers cannot find the .manifest file and therefore the website cannot be installed as a PWA.
I assume the problem/possible solution lies in the compiler/build options of vite, however I don't know how to fix this auto-conversion.
Here is the github repo: https://github.com/PluginDev-A/Website
the compiled index.html file is in the dist directory, the original index.html file is in the main directory. The problem is on line 6 of both files
**It does not matter whether the file-extention is .json or .webmanifest, both urls get converted upon build
That file should be probably placed in public directory because it is:
Never referenced in source code (e.g. robots.txt)
Must retain the exact same file name (without hashing)
And it should be referenced from index.html with absolute path
<link rel="manifest" href="/manifest.webmanifest">

Weird issue with download trigger

I have a flask app in which I have a front end html with multiple features.
This front end html template has a "download button" to download a file.
This is how I am triggering a download:
$('#download_excel').attr('onClick',"window.open('/static/excel.xlsx')");
download_excel corresponds to a bottom to download a file. This works fine.
But, if I move my excel.xlsx file to a different folder say "download" and modify the above line to this:
$('#download_excel').attr('onClick',"window.open('/download/excel.xlsx')");
This show no file here: (http://127.1.1.1:5555/download/excel.xlsx)
Why? what is the difference?
The problem is that Flask only serves files from the static folder. You have to specify another static folder path as described here: https://stackoverflow.com/a/9519004/5868802
This is because Flask has a default endpoint for static files (files accessible publicly) at /static. This endpoints binds to directory static in your project folder.
You can rebind this endpoint in Flask constructor:
Flask(__name__, static_url_path="/download", static_folder='download')

How do I access my files saved onto my express server?

Currently, I can 'upload' my images onto my server with Multer but now, how can I serve that file? If I visit the path which is: http://localhost:3001/public/backend/public/uploads/user-admin-1556247519876.PNG, i get a 404 cannot get.
I feel like i'm just missing a single step but I can't spot my error.
To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express.
For example, use the following code to serve images, CSS files, and JavaScript files in a directory named public:
app.use(express.static('public'))
Now, you can load the files that are in the public directory:
http://localhost:3000/images/kitten.jpg
http://localhost:3000/css/style.css
http://localhost:3000/js/app.js
http://localhost:3000/images/bg.png
http://localhost:3000/hello.html
Express looks up the files relative to the static directory, so the name of the static directory is not part of the URL.

ionic - change path of index.html

I have used the generator of app ionic start myApp blank as a start point.
But now I have special requirements of code's structure.
I must place in a same group the resource of the same type.
js directory for just js files
html directory for html files
and so on...
The problem here is index.html, I must move it from www directory to www/html directory, how can I achieve it?

How do I get App_Themes location in a html file using javascript

I am looking for a solution in javascript, where I can get the location to App_themes\Theme folder which contains theme files in asp.net. For example why this isn't so easy is because
when the virtual directory has been mapped directly to domain name then it would be domainname\App_Themes\themename\default.css but if virtual directory has been mapped to something else then how will I differentiate between the name and it could also be directory name?
If your app is in the same virtual directory as the theme file, then you can just use relative path.
If your app is in a different virtual directory, then no way to auto change the path when the virtual directory changed.

Categories