Previous topic

music21.webapps.commands

Next topic

Developer Reference

Table Of Contents

Table Of Contents

This Page

music21.webapps.templates

Webapps is a module designed for using music21 with a webserver.

This file includes templates detailing different output formats available for the CommandProcessor

Each template returns a tuple of the form (data, contentType).

Functions

music21.webapps.templates.braille(outputStream)

Takes in a stream outputStream, generates the braille representation of it, and returns the unicode output with content-type text/html for display in a browser

>>> sc = corpus.parse('bwv7.7').measures(0,2)
>>> (output, contentType) = webapps.templates.braille(sc)
>>> contentType
'text/html; charset=utf-8'
music21.webapps.templates.musicxmlFile(outputStream)

Takes in a stream outputStream and returns its musicxml with content-type ‘application/vnd.recordare.musicxml+xml’ for downloading

>>> sc = corpus.parse('bwv7.7').measures(0,2)
>>> (output, contentType) = webapps.templates.musicxmlFile(sc)
>>> contentType
'application/vnd.recordare.musicxml+xml; charset=utf-8'
>>> 'score-partwise' in output
True
music21.webapps.templates.musicxmlText(outputStream)

Takes in a stream outputStream and returns its musicxml with content-type ‘text/plain’ for displaying in a browser

>>> sc = corpus.parse('bwv7.7').measures(0,2)
>>> (output, contentType) = webapps.templates.musicxmlText(sc)
>>> contentType
'text/plain; charset=utf-8'
>>> 'score-partwise' in output
True
music21.webapps.templates.noteflightEmbed(outputStream)

Takes in a stream outputStream, and a string title. Returns the HTML for a page containing a noteflight flash embed of the stream and the title title

TODO: Change javascript and noteflight embed to relate to be server-specific

>>> sc = corpus.parse('bwv7.7').measures(0,2)
>>> (output, contentType) = webapps.templates.noteflightEmbed(sc)
>>> contentType
'text/html; charset=utf-8'
music21.webapps.templates.vexflow(outputStream)

Takes in a stream outputStream, generates an HTML representation of it using vexflow, and outputs it with content-type text/html for displying in a browser.

>>> sc = corpus.parse('bwv7.7').measures(0,2)
>>> (output, contentType) = webapps.templates.vexflow(sc)
>>> contentType
'text/html; charset=utf-8'