Sample project: Python 3.10
If you want a Python newer than the 3.7 that comes with the project container, here you go. Now you can install things that require newer Python and use new language and standard library features.
Here I’m using the new match
syntax from Python 3.10:
import math
import flask
app = flask.Flask(__name__)
@app.route('/')
def index():
return flask.send_file('index.html')
@app.route('/test/<command>')
def test(command):
# check this out, match!
# https://peps.python.org/pep-0636/
match command.split('-'):
case ['add', a, b]:
return str(int(a) + int(b))
case ['multiply', a, b]:
return str(int(a) * int(b))
case ['ln', x]:
return str(math.log(float(x)))
case _:
flask.abort(400)