Skip to main content

Flask WSGI server for sharing individual rows of spreadsheets with CAS-authenticated users named in those rows.

Project description

Refraction

Overview

This program is a flask WSGI app for serving views of spreadsheets to individuals whose usernames (authenticated via a Central Authentication Service a.k.a. CAS) appear in a particular column of the spreadsheet. For example, you could allow each user to view their row in a gradesheet. It supports integration with Google Sheets as well as storing manually uploaded CSV or TSV files.

Dependencies:

  • Python version 2.7 or 3.6+
  • flask, flask_cas, jinja2, and markupsafe for server support
  • redis which is used for data storage. You will need to separately install the redis executable and make sure it's launchable by your web server (or you can launch redis manually).
  • google and googleapiclient are used for Google Sheets integration, but can be ignored if you're not using that.
  • flask_talisman is highly recommended; without it the server won't force HTTPS and will be much less secure; and flask_seasurf is also recommended to help prevent Cross-Site Request Forgery (CSRF).
  • OpenSSL is necessary if you want to run in debug mode using HTTPs.
  • pytest for testing, install with [test] option to get it automatically.

Installing

Run pip install refraction which will install the refraction module.

You can then run python -m exploration.tests to run tests.

NOTE: Right now, tests are broken and will not pass in one phase, and will leave a running redis server...

Getting Started:

To set up the server, you'll need to create a directory for running it from that has certain files (this can be anywhere on your system). The rundir directory in the installed module has an example of what you'll need, complete with configuration files you can edit.

The main files you will need to change are rf_config.py and refraction-admin.json: the former has things like the CAS setup in it, while the latter needs to list app-wide administrators who will be able to access everyone's data (or you can leave the admins list empty).

Once these files have been edited, if you want to use Google Sheets, you'll also have to set up a service account via a Google Cloud project (you won't need to pay for anything). You'll need a credentials file to authenticate as the service account (TODO: Detailed steps for that!) and that must be in your run directory.

When your run directory is set up and you've edited your configuration files, run:

python -m refraction.app

This will start the server locally, and you can test things out. Note that in some cases a redis instance may remain after you're done testing; you can kill that process manually.

TODO: Redis cleanup on local server shutdown?

To run the server for real, make sure that you have CAS set up in the configuration file (you'll need access to a CAS server, which you might have via a company or academic institution). You should also make sure to install flask_talisman and flask_seasurf.

Whatever web server you're running should supply a WSGI layer (e.g., Apache has mod_wsgi). Use this to actually get the server running; the refraction.wsgi file in the run directory can be the target. For example, using Apache mod_wsgi your configuration file might look like this:

# =================================================
# Refraction App for spreadsheet sharing row-by-row

# the following is now necessary in Apache 2.4; the default seems to be to deny.
# TODO: Does this make these files served up?
<Directory "/home/refraction/rundir">
    Require all granted
</Directory>

WSGIDaemonProcess refraction user=refraction processes=5 display-name=httpd-refraction home=/home/refraction/rundir python-home=/home/refraction/refraction-python python-path=/home/refraction/rundir
WSGIScriptAlias /refraction /home/refraction/rundir/refraction.wsgi process-group=refraction

This example configuration assumes that you've created a user named refraction, and put your run directory rundir in the home directory of that user.

Plans

  • All-user views to support things like Q&A.

Changelog

  • v0.1 Initial pre-alpha upload.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

refraction-0.1.tar.gz (58.0 kB view details)

Uploaded Source

Built Distribution

refraction-0.1-py3-none-any.whl (46.4 kB view details)

Uploaded Python 3

File details

Details for the file refraction-0.1.tar.gz.

File metadata

  • Download URL: refraction-0.1.tar.gz
  • Upload date:
  • Size: 58.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for refraction-0.1.tar.gz
Algorithm Hash digest
SHA256 fee5891f25807f533dd5f5a1408a1648bdf6c56a5cd20c100208872c99966d1c
MD5 1e6b764a9c417c851f595d9d3c50a4ce
BLAKE2b-256 5cde27a055ec02df100f5f0717381408d80cbd8eb507f7cd7e521fdfb1005d97

See more details on using hashes here.

File details

Details for the file refraction-0.1-py3-none-any.whl.

File metadata

  • Download URL: refraction-0.1-py3-none-any.whl
  • Upload date:
  • Size: 46.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for refraction-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0cdf01b1103336ab486fdf50adf8aa73e615b6add6abc6d30689f2944c3593a0
MD5 553a999f24ea6709b9a7fe5162e8516a
BLAKE2b-256 a0cf873fcbabce6a91ef0d692b2f24b229ad2dbbf471209f8f6155adaf782775

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page