I've created a Flask API which I want to be hit/refreshed at every second.
Following is the code:
from flask import Flask
from datetime import datetime
app = Flask(__name__)
@app.route("/", methods=["GET"])
def home():
return """Hello World!<br>The current time is {}.""".format(datetime.strftime(datetime.now(), "%d %B %Y %X"))
if __name__ == "__main__":
app.run()
What is desired?
I basically want the html page to update every second, showing the current date & time, ie., updating every second.
I haven't added any explicit HTML page for rendering. I don't know HTML and therefore wanted to get this done via python and flask apis.
How can I achieve this? Is there any better way of doing this?