static-files

Serve static files in Flask from private AWS S3 bucket

痞子三分冷 提交于 2020-02-23 11:48:05
问题 I am developing a Flask app running on Heroku that allows users to upload images. The app has a page displaying the user's images in a table. For developing purposes, I am saving the uploaded files to Heroku's ephemeral file system, and everything works fine: the images are correctly loaded and displayed (I am using the last method shown here implying the use of send_from_directory()). Now I have moved the storage to S3 and I am trying to adapt the code. I use boto3 to upload the files to the

Golang handle static folder

情到浓时终转凉″ 提交于 2020-01-30 13:16:08
问题 I'm not able to get files placed in static folder. I'm using gorilla mux package. main.go code: fs := http.FileServer(http.Dir("static")) mainRouter.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fs)) http.Handle("/", &mainRouter) Project structure: static templates --style --javascript --... main.go When I hit index page: loclalhost:8080/cruise_schedule I get all stylesheets and js files, but when I jump to another page: localhost:8080/cruise_schedule/selected_cruise

Django - Static file not found

旧时模样 提交于 2020-01-27 03:23:28
问题 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/

Django - Static file not found

不羁岁月 提交于 2020-01-27 03:22:09
问题 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/

Static files on asp.net core

假如想象 提交于 2020-01-24 15:57:50
问题 I am trying to enable static files on an ASP.NET Core 2.0 web application. I have a bunch of files in a folder called updater which resides outside the wwwroot folder. To allow access to them I added app.UseStaticFiles(new StaticFileOptions() { ServeUnknownFileTypes = true, FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), @"TestUpdater") ), RequestPath = new PathString("/Updater") }); This lets a different program to be able to get its files by calling

Leverage browser caching with web.config in .net?

最后都变了- 提交于 2020-01-12 14:12:51
问题 Some of sites are on shared hosting (Windows 2003 Server), so I have no way to access server configuration. I read everywhere about leverage browser caching, expecially for static files (jpg, css, js, etc.) but... how to do this in my case? The hosting has .NET installed, could a web.config file help in some way? If yes, how? 回答1: Here is how I did on my site that is on a shared host. I believe the cacheControlMaxAge is as follows days:hours:minutes:seconds but dont quote me. <system

Wildfly Undertow File Mimetypes

梦想与她 提交于 2020-01-05 07:46:07
问题 I want Undertow to serve static files like .jpg, .png, .js, .css, .txt etc... I edited the undertow subsystem in standalone.xml: <subsystem xmlns="urn:jboss:domain:undertow:4.0"> <buffer-cache name="default"/> <server name="default-server"> <http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/> <https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/> <host name="default-host" alias="localhost">

Trouble locating static audio file on Google App Engine

谁说胖子不能爱 提交于 2020-01-04 06:10:51
问题 I have a project directory and a sub directory set up as such: /proj_dir /proj_dir/audio app.yaml: handlers: - url: /.* script: main.py - url: /audio static_dir: audio main.py is a simple Python program that, on a GET request, outputs the "index.html" file also in the proj_dir directory. The index.html file contains some javascript code that plays the audio file. The problem is that index.html plays the audio file without issue when run locally. Once deployed, however, I get a 404 when trying

How to serve static file with a hebrew name in python bottle?

五迷三道 提交于 2020-01-04 02:07:12
问题 I receive a request from the client to download some file from the server. The filename is in Hebrew. @bottle.get("/download/<folder_name>/<file_name>") def download(folder_name, file_name): file_name = file_name.decode('utf-8') folder_name = folder_name.decode('utf-8') if os.path.exists(os.path.join(folder_name, file_name)): return bottle.static_file(file_name, root=folder_name, download=True) The last line fails : return bottle.static_file(file_name, root=folder_name, download=True) I get

Express.js 4 - use middleware for authentication before static files

雨燕双飞 提交于 2020-01-03 18:51:09
问题 In my express app I've set static files to be served from the /public directory with this line: app.use(express.static(__dirname + '/public')); Now I need to add a middleware for authentication before serving the static content and if the user is not authenticated to be redirected to a route for authentication (e.g., /login ). I'm not really sure how I have to do it. Any ideas? 回答1: Since you didn't specify it, I'm going to assume that you already have some kind of authentication system. In