Skip to content
Sign upLog in
← Back to Community

How do I get a URL to a file inside of a repl HTML5 project? [SOLVED]

Profile icon
Prowse

Is there a way to reference a single file inside my HTML5 project? For example, if I wanted to reuse the JS file, can I reference just the JS file inside the project? I've tried having a script tag reference the project URL, and the project URL followed by the filename, but that doesn't work; the latter gives a 404.

Answered by Vandesm14 [earned 5 cycles]
View Answer
Voters
Profile icon
sampush
Profile icon
nPauuul
Profile icon
InvictusLex
Profile icon
Prowse
Comments
hotnewtop
Profile icon
Vandesm14

Can you provide a link to your reply?

Profile icon
Prowse

@Vandesm14
I'm not sure what you mean by reply. This isn't a project specific question, it's more general in that (as part of trying to answer my other question) I'm wondering if repl.it even provides the ability to read a single file out of a project that has multiple files via a URL. I'm hoping somebody from repl.it can just answer whether this feature exists or not.

Profile icon
Vandesm14

@Prowse
(reply was Repl but autocorrected)

You can reference script files using <script src="the-url"></script>
To view text files, it is recommended that you use an Express.js server on repl.it to asynchronously serve the files.

Please upvote this if it helped you out 👍

Profile icon
Prowse

@Vandesm14
Right, but how do you reference the script.js file INSIDE of a repl.it project? How do I get a URL to that individual file?

Profile icon
Vandesm14

@Prowse
The url will be here
Invalid image url

Profile icon
Vandesm14

@Prowse
The url will be here

Cannot infer image mime type

Profile icon
Prowse

@Vandesm14
Genius! That worked after I added the script.js filename to the end of the URL. Great help!

Profile icon
InvictusLex

5151

Profile icon
UtshaPaul

Invalid image url

Profile icon
Zeune

Could you just copy the js file you need to your project locally and then reference it?

Profile icon
Prowse

@Zeune
Yes, of course, but I want to maintain individual classes inside of separate projects so that I can reuse them in new projects. I don't want to keep track of 5 versions of a class that have been copied into 5 other projects. I want to centralize these shared files in their own locations and just reference these locations in my other files.