Skip to content

Repository files navigation

SimplyPoetry

SimplyPoetry is a Python Web App for writing your own and submitting poetry, so far, locally to a development server.

The end goal is to create a Web Server that will collect all submissions from users so that users can share their creative work.

Installation

Use the package manager pip to install the Flask web framework.

pip install Flask

File & Folder Path:

.
├── app.py
├── __init__.py
├── poetry_forms.py
├── __pycache__
│   └── poetry_forms.cpython-312.pyc
└── templates
    └── index.html

Usage

app.py

from flask import Flask, render_template, request, jsonify
from poetry_forms import poetry_forms as language_poem_form

app = Flask(__name__)

@app.route('/')
def index():
    languages = list(language_poem_form.keys())
    return render_template('index.html', languages=languages)

@app.route('/get_forms')
def get_forms():
    selected_language = request.args.get('language')
    forms = language_poem_form.get(selected_language, {})
    return jsonify(forms)

@app.route('/index', methods=['GET', 'POST'])
def text_box():
    submitted_text = None
    if request.method == 'POST':
        submitted_text = request.form['text_input']
    languages = list(language_poem_form.keys())
    return render_template('index.html', languages=languages, submitted_text=submitted_text)

if __name__ == '__main__':
    app.run(debug=True)

poetry_forms.py

poetry_forms = {
    "English": {
        "Haiku": {"syllables": [5, 7, 5], "lines": 3},
        "Sonnet": {"syllables": [10] * 14, "lines": 14},  # Iambic pentameter, 10 syllables per line
        "Limerick": {"syllables": [8, 8, 5, 5, 8], "lines": 5}
    },
    "Chinese": {
        "Jueju": {"syllables": [5, 5, 7, 7], "lines": 4},  # 5 or 7 syllables, regulated tone
        "Lüshi": {"syllables": [5] * 8, "lines": 8},      # 5 or 7 syllables, strict parallelism
        "Ci": {"syllables": "variable", "lines": "variable"}  # Depends on tune pattern
    },
    "Japanese": {
        "Haiku": {"syllables": [5, 7, 5], "lines": 3},
        "Tanka": {"syllables": [5, 7, 5, 7, 7], "lines": 5},
        "Senryu": {"syllables": [5, 7, 5], "lines": 3}
    },
    "Indian": {  # Sanskrit and regional traditions
        "Shloka": {"syllables": [8, 8], "lines": 2},  # Typically 8 syllables per half-line, epic form
        "Ghazal": {"syllables": "variable", "lines": 10},  # Urdu influence, 5+ couplets
        "Doha": {"syllables": [13, 11], "lines": 2}  # Hindi/Prakrit, syllable split per line
    },
    "Vietnamese": {
        "Luc Bat": {"syllables": [6, 8] * 3, "lines": 6},  # Alternating 6 and 8, extensible
        "Song That": {"syllables": [7] * 4, "lines": 4},  # 7 syllables, folk style
        "Cach Dieu": {"syllables": "variable", "lines": 4}  # Regulated, varies by tone
    }
}

[SimplyPoetry] (https://github.com/thejonathanjin/SimplyPoetry/blob/main/pythonPoetryV5/screenshots/simply_poetry.png?raw=true)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

A major thanks to Jonathan Tuan Tran and Sahil Gupta for initiating this project!

License

Creative Commons

[The Unlicense] (https://choosealicense.com/licenses/unlicense/) p

About

A simple Python Web App for reminding writers how many syllables are in each type of poem

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages