-1

If I have a route:

@app.route("/api")
def api():
    return some_val

And then some_val changes, I need to restart the server for the route to display the new value (I read/write it to a file). How do I make routes dynamically update their content? Is it even possible? Thanks!

PG Cubing
  • 11
  • 5

1 Answers1

0

this might do the trick!

import random
@app.route("/api")
def api():
    return str(random.random())

or this might be fun! don't forget to install fortune in linux!

import subprocess
@app.route("/api")
def api():
    return subprocess.check_output('fortune')
rho
  • 771
  • 9
  • 24