Ananth Duari
Ananth Duari

Reputation: 2879

Run Flask application with Jython

I want to run a Flask application with Jython, but I am not able to find anything. Is it possible to combine Flask and Jython? I know Django is still in a beta version with regard to Jython support.

Upvotes: 3

Views: 3647

Answers (1)

davidism
davidism

Reputation: 127180

Yes, this is possible without any changes. Do it just like you would using the standard cpython. Create a virtualenv (pointing at Jython), install Flask, run your program.

virtualenv -p /opt/jython/bin/jython venv
. venv/bin/activate
pip install Flask

hello.py:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello, World!'
FLASK_APP=hello.py FLASK_DEBUG=1 flask run

When running in production, you do not want to use the dev server. Use an application server like Tomcat: What's the best way to deploy a Flask app using Jython on Tomcat?

Upvotes: 1

Related Questions