static-files

Use nginx to serve static files from subdirectories of a given directory

浪尽此生 提交于 2019-11-27 17:57:55
I have several sets of static .html files on my server, and I would like use nginx to serve them directly. For example, nginx should serve an URI of the following pattern: www.mysite.com/public/doc/foo/bar.html with the .html file that is located at /home/www-data/mysite/public/doc/foo/bar.html . You can think of foo as the set name, and bar as the file name here. I wonder whether the following piece of nginx config would do the job: server { listen 8080; server_name www.mysite.com mysite.com; error_log /home/www-data/logs/nginx_www.error.log; error_page 404 /404.html; location /public/doc/ {

Node JS not serving the static image

孤街醉人 提交于 2019-11-27 16:23:36
I have already added the codes for serving an image on my node server but it seems to not serve images in the HTML when connecting to Node. I have also external CSS and JS that are being served correctly. Here is the fragment of my code in Node (See below). Thank you in advance! var server = http.createServer(function(req, res) { var pathname = url.parse(req.url).pathname; var ext = path.extname(pathname); var handler = handlers[req.url]; if(ext) { if(ext === ".css"){ res.writeHead(200, { "Content-Type" : "text/css" }); } else if(ext === ".js") { res.writeHead(200, { "Content-Type" : "text

Using static files with the django virtual server

南楼画角 提交于 2019-11-27 16:17:21
Questions exactly like this have been asked before, i've read them all and tried to make sense of the official django documentation on the subject but i'm still struggling to use static files on the virtual server. More specifically i'm just trying to get my template, Base.html , to use base.css. My folder structure looks like this: manage.py static/CSS/base.css VergeGreenITEvent_Website/settings.py VergeGreenITEvent_Website/views.py ect VergeGreenITEvent_Website/Webpage_Templates/Base.html (no app folder at the moment, as I was following "The django book" to learn and hadn't gotten to that

Prevent IIS from serving static files through ASP.NET pipeline

你说的曾经没有我的故事 提交于 2019-11-27 12:21:55
Requests for my css, js, image files are being served through the ASP.NET pipeline. I thought IIS by default avoided this, but I see the requests on my Application_AuthenticateRequest breakpoint and there's no need to actually authenticate those requests. I've seen conflicting approaches to change this behavior - What is the best way to do this? I'm taking a guess here and suspect that you have the following setting configured in your web.config file: <modules runAllManagedModulesForAllRequests="true"> This means that every request, including those for static content is hitting the pipeline.

Django Static Files Development

旧街凉风 提交于 2019-11-27 11:43:01
This seems to be a source of much confusion judging by the amount of similar titles on the subject, however trying everything I could find on static files with the django development server I've almost given up hope! So my static files are served from C:/Users/Dan/seminarWebsite/static/ , in which I have sub folders for images, css etc. SETTINGS: STATIC_ROOT = 'C:/Users/Dan/seminarWebsite/static/' STATIC_URL = '/static/' The static files app is also active. URLS: from django.contrib.staticfiles.urls import staticfiles_urlpatterns urlpatterns += staticfiles_urlpatterns() TEMPLATE: "{{ STATIC

What's the point of Django's collectstatic?

爱⌒轻易说出口 提交于 2019-11-27 11:00:35
This is probably a stupid question, but it's just not clicking in my head. In Django, the convention is to put all of your static files (i.e css, js) specific to your app into a folder called static . So the structure would look like this: mysite/ manage.py mysite/ --> (settings.py, etc) myapp/ --> (models.py, views.py, etc) static/ In mysite/settings.py I have: STATIC_ROOT = 'staticfiles' So when I run the command: python manage.py collectstatic It creates a folder called staticfiles at the root level (so same directory as myapp/) What's the point of this? Isn't it just creating a copy of all

Django - Static file not found

落爺英雄遲暮 提交于 2019-11-27 10:55:17
I've seen several posts for this issue but didn't found my solution. I'm trying to serve static files within my Django 1.3 development environment. Here are my settings ... STATIC_ROOT = '/home/glide/Documents/django/cbox/static/' STATIC_URL = '/static/' STATICFILES_DIRS = ( '/static/', ) ... My urls.py urlpatterns = patterns('', ... url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root', settings.STATIC_ROOT} ), ... ); My /home/glide/Documents/django/cbox/static/ directory is like css main.css javascript image I get a 404 error when trying to access http://127.0.0.1:8000

What is the best practice for serving html in node.js with express.js?

梦想与她 提交于 2019-11-27 10:32:27
问题 I currently am serving all my html right in my app.js/server.js file like this: app.get('/', function(req, res) { res.render('index.html'); }); app.get('/about', function(req, res) { res.render('about.html'); }); app.get('/projects', function(req, res) { res.render('projects.html'); }); I imagine if I have 15+ html pages that this is probably not the best way to call them. Is there a better way to serve them from another file or location and using export or something to be able to call just

Django — Can't get static CSS files to load

纵饮孤独 提交于 2019-11-27 06:52:34
I'm running Django's development server ( runserver ) on my local machine (Mac OS X) and cannot get the CSS files to load. Here are the relevant entries in settings.py: STATIC_ROOT = '/Users/username/Projects/mysite/static/' STATIC_URL = '/static/' STATICFILES_DIRS = ( '/Users/thaymore/Projects/mysite/cal/static', ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', #'django.contrib.staticfiles.finders.DefaultStorageFinder', ) INSTALLED_APPS = ( # other apps ... 'django.contrib.staticfiles', ) In my views.py

Deploy Nodejs on Heroku fails serving static files located in subfolders

a 夏天 提交于 2019-11-27 05:01:31
I'm deploying a NodeJs application using Heroku. Everything works fine except a little issue serving static files. I have the following configuration app.use(express.static(__dirname + '/htdocs')); It works fine except when I try to serve static files located in sub folders. www.example.com/bar.js // this serves the file /htdocs/bar.js www.example.com/foo/bar.js // this can't find the file /htdocs/foo/bar.js I forgot to say that on my local environment everything works fine, might be something with heroku but I can't find the reason. Did someone had this problem before? Solutions? Thanks!