mellow-yellow
mellow-yellow

Reputation: 1810

WSGI Web frontend (using jquery, AJAX, css) for python backend

Disclaimer: I am new to python but have coded in Drupal where I used ajax, jquery, json

I need to create a simple web app front-end (using jquery, AJAX, css) for my python backend. I successfully followed the instructions on this stackoverflow question page, but the WSGI-served html refuses to load my html's stylesheets and jquery.js. In the previously mentioned link, S.Lott wrote, "The demo_app is relatively easy to write; it handles your Ajax requests." I (believe that I) understand the demo_app and much of his "WSGI implementation," but obviously not enough. I'm happy to research the answer but need a nudge in the right direction. Thanks!

Upvotes: 2

Views: 1793

Answers (1)

Mariusz Jamro
Mariusz Jamro

Reputation: 31653

WSGI is an interface between the webserver (like Apache) and your Python web application. It provides a standard way of running Python code on web servers.

You do not need WSGI to serve static files like JavaScript or CSS (because JS/CSS is not a Python code). Configure your web server to serve static files in a normal way, apart of your WSGI-based Python web application.

With Apache typical solution is to use Alias directive:

Alias /media/ /usr/local/www/documents/media/              # Static files, e.g. http://example.com/media
WSGIScriptAlias / /usr/local/www/wsgi-scripts/myapp.wsgi   # WSGI app mounted at the root of site, e.g. http://example.com

Upvotes: 1

Related Questions