paule.tech

Web App Specialist

End-to-end

My native stack is:

  • Apache
  • MySQL
  • Django
  • AngularJS
  • Arduino

Most of the necessary parts come preinstalled with OSX

My Introduction to Django

Django is a super handy web framework built on Python. I first discovered it while looking for something compatible with the Apache2 install on my Mac.

 

At first I was only looking to make the HTML templates dynamic. Of the obvious options, It came down to PHP or Django. The deciding factor ended up being something I’d not even considered at the start: clean URLs!

 

The ease of clean URLs in Django is remarkable. Regular expressions are the name of the game.

Apache Basic Setup

Apache2

Apache2 conveniently ships with OSX. I use it locally in a Virtual Hosting setup. It more or less mirrors the Django recommendations and runs a WSGI process to integrate the python application.

<VirtualHost *:443>
DocumentRoot “/Users/Paul/Sites”
DirectoryIndex index.html

<Directory “/Users/Paul/Sites”>
Options All -Indexes -ExecCGI -Includes +MultiViews
AllowOverride None

RewriteEngine on

# Don’t rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ – [L]

# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
</Directory>

Alias /app “/Users/Paul/Sites/”

Include /Library/Server/Web/Config/apache2/httpd_wsgi.conf

</VirtualHost>

Interestingly (to some) you don’t need mod_python in Apache to use the python application; WSGI configuration is sufficient.

WSGIDaemonProcess paule.tech processes=2 threads=15 display-name=%{GROUP} python-path=/Library/WebServer/site/:/Users/paul/.virtualenvs/venv-python2.7-django/lib/python2.7/site-packages
WSGIProcessGroup paule.tech