Skip to content

Instantly share code, notes, and snippets.

@aodhan-domhnaill
Last active February 22, 2019 15:12
Show Gist options
  • Save aodhan-domhnaill/05a2643c01dd4ffd533b640bbb95187b to your computer and use it in GitHub Desktop.
Save aodhan-domhnaill/05a2643c01dd4ffd533b640bbb95187b to your computer and use it in GitHub Desktop.
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/")
def root():
return """
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
function forward() { $.ajax({url: "/forward"}) }
</script>
<button onclick="forward()">Forward</button>
</html>
"""
@app.route("/forward")
def forward():
print("Robo go forward!")
return jsonify({
"message": "Robot just went forward"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment