Last active
January 3, 2016 15:29
-
-
Save natronics/8482894 to your computer and use it in GitHub Desktop.
Simple button on a webpage. Bootstrap for style.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from flask import Flask, render_template, url_for, redirect, request | |
import os | |
tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), './') | |
app = Flask(__name__, template_folder=tmpl_dir) | |
@app.route("/", methods=['GET', 'POST']) | |
def index(): | |
if request.method == 'POST': | |
print request.form | |
return render_template('index.html') | |
@app.route("/action/<act>") | |
def action(act): | |
print act | |
return redirect(url_for('index')) | |
if __name__ == "__main__": | |
app.debug = True | |
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<link href="/static/bootstrap.min.css" rel="stylesheet"> | |
<link href="/static/style.css" rel="stylesheet"> | |
<title>Pushing Buttons, Sending Messages</title> | |
</head> | |
<body> | |
<div class="container"> | |
<h1>Page Title</h1> | |
<hr> | |
<div class="row"> | |
<p id="foo" class="col-sm-2"> | |
Text and stuff. Write something. | |
</p> | |
<p id="bar" class="col-sm-2">asdf</p> | |
</div> | |
<div> | |
<a class="btn btn-primary" href="/action/doesntexist">Push me</a> | |
</div> | |
<hr> | |
<div> | |
<form method="post"> | |
<button value="submit" name="one" class="btn btn-primary">Push me too</button> | |
<button value="submit" name="two" class="btn btn-primary">Another</button> | |
</form> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment