python - Serving static files from root of Django development server -


my goal have angular project being served root of development server. files static far django concerned, no django template processing needed. angular project make resource calls django project located @ /api/ on same development server, return json results generated view angular project process.

i assumed easy adding following urls.py file.

url(r'^/', 'django.views.static.serve', {         'document_root':'/users/kyle/development/project/site/app', }), 

or

+ static("^/$", document_root="/users/kyle/development/project/site/app") 

to end of urlpatterns.

with /project/site/app being directory angularjs files.

however, both of these leave me 404 errors.

i'm open changing structure of project if more obvious solution exists.

  1. note default django won't serve directory listing. still 404 if file /users/kyle/development/project/site/app/beer.jpg doesn't appear http://localhost/beer.jpg ?

  2. in urls.py urls don't start slash; compare url(r'beer') url(r'^/beer')

i suggest going standard static support. it's awkward, lets serve file during development, , switch 3rd party server (ie nginx) production:

https://docs.djangoproject.com/en/dev/howto/static-files/


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -