Where can i place static contents under Jetty webserver? - web-services

i need to place some static contents under jetty directory , anybody knows where to place them ?

You can compile the static files in a WAR and deploy the war in your webapps folder. A request for a URL path that matches a path to a file in the WAR is considered a static file. HTH

Related

Problem with static folder IIS for Django

I have a static folder set in django to a network path
STATICFILES_DIRS = [
"//SERVER/Shared1/FOLDER_210121/",
]
and I have 2 pages that have links to this static subfolders
link1: http://server2:8044/static/folder1/COINS_LIVE_OU164/user1310200781810167.tif
link2: http://server2:8044/static/folder2/COINS_LIVE_OU164/user2310200781810167.tif
however link1 works perfectly but link 2 gives me an error as file not found
but the file does exist, and from IIS I have set a virtual directory aliased as "static" with the root folder that contains the subfolder from where I get the files.
I can navigate from the virtual directory to both files, the virutal directory was created with the defaultAppPool user.
is there something else I could check?
(if I run the manage.py runserver command and I use localhost I can download both files, the issue is when using it from the IIS).
if I print the value of static in a label the path is ok, so I'm guessing permission, but where can I be missing the configuration?
Thank you.
Adding a bit more info:
the issue affects a subfolder inside the "static" folder, 1 can enter without probelms, the other can't.
I'm getting crazy. I deleted all, created again, and the issue still occurs.
I was able to solve my particualr problem, it was fixed by putting the static handler module mapping alone with the Django FastCGI (custom) module in the website IIS

How can I store my static files to some other github repo?

I am doing a Django Project and I want to store some files (which should be accessible from the project w,r) to some github project as I don't want to store the files and the projects in the same repo.
Any suggestion of doing that?
Let's say, for example, that you want to upload all files with a .css extension to a separate project.
You need to create two files in the root folder of each project. and call them .gitignore
(Don't forget the point at first)
In the repository where you want all files except css files, write in the .gitignore file:
*.css
In the repository where you only want the css files, write in the .gitignore file:
*
!*.css
You will now push the .gitignore files, respectively, to each of the projects you created.

More that one path for static files with django on IIS

With django (python server) is possible to add more that one path to serve static files using STATICFILES_DIRS = ("C:/some/path/static_two",) on settings file, and works fine, but on production server, in my case IIS, is that possible?
I tried adding two virtual dirctories each one whit different paths/locations, but doesn't works, the static file from the second directiry "C:/some/path/static_two" doesn't shows.
Someone can help me on how configurate IIS two serve static files from more that one location.
thanks in advance.
You are confused about what that setting does.
STATICFILES_DIRS is the place(s) where static files are copied from when you run manage.py collectstatic. The place they are copied to is STATIC_ROOT, which is a singular directory. You need to set up your web server to serve files from there, not from STATICFILES_DIRS.

How to hide the full directory when serving static files with Apache

I am using Django and Apache.
I am serving the static files with Apache. It works well, the problem is, when a user go to the url http://urlOfMySite.com/static, he can see the whole directory and navigate in it.
I'm using : Alias /static /var/www/MySite/app/app/static in Apache VirtualHost to serve static files.
Is there any way to hide it from user? (make the static files accessible, but not the full directory browsable).
Thanks
Your problem is about the apache server itself, you need to disable indexing for that folder with "Options -Indexes" inside the "directory" clause to specify which folder you want to apply this command. More info:https://wiki.apache.org/httpd/DirectoryListings#Directory_Listings
Btw, this is odd, by default, when I deploy using Apache, I don't need this =/.

Why use Django's collectstatic instead of just serving the files directly from your static directory?

From the Django Docs:
Deployment django.contrib.staticfiles provides a convenience
management command for gathering static files in a single directory so
you can serve them easily.
Set the STATIC_ROOT setting to the directory from which you’d like to
serve these files, for example:
STATIC_ROOT = "/var/www/example.com/static/"
Run the collectstatic management command:
$ python manage.py collectstatic
This will copy all files from your
static folders into the STATIC_ROOT directory.
Use a web server of your choice to serve the files. Deploying static
files covers some common deployment strategies for static files.
What's the purpose of copying the files, why not just serve them from the directory they live in within the app?
Why not just serve your static directory? You might use more than one app, and some of your apps may not be under your control. Before the staticfiles app existed, you then had to either manually copy the static files for all apps to a common directory, upload them to your CDN, or symlink them to the document root of your web server.
The staticfiles app established a convention: put static files for each app under a static directory and let Django do the work for you.
The STATIC_ROOT can be on a different machine than the application, so copying your static files to the static root means that you can serve your static files from a different server (CDN FTW!) which you wouldn't be able to do if those files where only located within their respective app directories.