Ophot - a photography portfolio web application


This is Ophot, a small web application which provides a simple photography portfolio website. It allows a manager to log in in order to add, edit or remove photos.

This document contains some brief information on requirements, installation, configuration, and building documentation.

This README was last updated on 5 January 2012.

The code comprising this web application is copyright 2012 Jeffrey Finkelstein, and is published under the GNU Affero General Public License, either version 3 or (at your option) any later version. For more information see the LICENSE file.


This is a partial listing of the contents of this package.

  • doc/ - the Sphinx documentation for Ophot
  • LICENSE - the copyright license under which this program is distributed to you (the GNU Affero General Public License version 3 or later)
  • ophot/ - the Python package containing the application itself
  • ophot.wsgi - the WSGI specification file which runs the application when deployed to a server as a WSGI application
  • README.md - this file
  • scripts/ - utility scripts for developing Ophot and managing installed Ophot systems
  • setup.py - Python setuptools configuration file for packaging this application
  • TODO - tasks to be done for developers of this application

The ophot/ directory is a Python package and contains the following files:

  • api/categories.py - RESTful API for categories of photos
  • api/photos.py - RESful API for photos
  • api/user.py - RESful API for user settings
  • app.py - module containing the Flask application object
  • config.py - configuration for the application and some settings for user-visible parts of the site
  • filters.py - filters for use with the Jinja2 templates in the templates/ directory
  • schema.sql - the schema for the photo database
  • static/ - the static content for the site, including scripts and styles
  • templates/ - the Jinja2 templates defining the dynamically generated HTML pages for the site
  • tests/ - the unit tests for the Python code in this package
  • views.py - functions which process routes which are the views for users of the site


This application requires Python 2.7.

This application requires the following libraries to be installed:

Using pip is probably the easiest way to install these:

pip install Flask Flask-Login Flask-Uploads Flask-WTF Pillow configobj

Building as a Python egg

This package can be built, installed, etc. as a Python egg using the provided setup.py script. For more information, run

python setup.py --help


To configure this application, edit the configuration file config.py. You must add at least USERNAME, PASSWORD, and SECRET_KEY for allowing the administrator to log in. You probably want to change the value of NAME, plus some others as well.

Instead of editing the configuration file directly, you can set the OPHOT_SETTINGS environment variable to be the path to a file containing the configuration settings which you wish to override. For example, create a text file called myconfig and add the following:

USERNAME = 'myusername'
PASSWORD = 'mypassword'
SECRET_KEY = '123456789012345678901234'

(See the config.py file for more information on how to generate a secret key.) Next change the OPHOT_SETTINGS environment variable to point to that file:

export OPHOT_SETTINGS=/path/to/myconfig

Place the above command at the bottom of the file $HOME/.bash_profile in order to set that environment variable on every login:

echo OPHOT_SETTINGS=/path/to/myconfig >> $HOME/.bash_profile


Before running the application we also need to initialize the database. The reset-db.sh script will create the database for you based on the schema in the schema.sql file:


To run the web server and start serving, run:

python scripts/runserver.py

Remember to disable debug mode when running on a production server.

One can also deploy this application as a WSGI application, using, for example, mod_wsgi for Apache. To deploy this application as a WSGI application, edit the first two lines in the ophot.wsgi file from

PATH_TO_APP = '/var/www/ophot'
PATH_TO_VIRTUALENV = PATH_TO_APP + '/env/bin/activate_this.py'

to be the correct paths to the top level directory of the application and the virtualenv environment in which the application should run, respectively.


The Python unit tests are contained in the ophot/tests/ directory (which is a Python package). To run the test suite, run the command

python setup.py test

Building documentation

Ophot requires the following program and supporting library to build the documentation:

Using pip is probably the easiest way to install these:

pip install sphinx sphinxcontrib-httpdomain

The documentation is written for Sphinx in reStructuredText files in the doc/ directory. Documentation for each class and function is provided in the docstring in the code.

To build the documentation, run the command

python setup.py build_sphinx

in the top-level directory. The output can be viewed in a web browser by opening build/sphinx/html/index.html.


Jeffrey Finkelstein jeffrey.finkelstein@gmail.com