OS: Linux Mint 17.2
Using Anaconda Distribution Python
The following worked for installation of pymks.
This walks through setting up sfepy as well
I asked this question a few weeks ago in the Raspberry Pi Forum's. | |
Unfortunately no one got back to me. | |
I am sure there is a simple solution to my problem. | |
So I am making a really simple webapp, which has two buttons. | |
One button starts a blink sequence on a multi-colored LED. | |
The other button turns the multi-LED completely off. | |
The blink sequence requires a loop. | |
The loop freezes the webapp. |
OS: Linux Mint 17.2
Using Anaconda Distribution Python
The following worked for installation of pymks.
This walks through setting up sfepy as well
Persuading WTForms to Generate Checkboxes | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
WTForms takes the pain out of handling forms and validation, you define your form, | |
tell it what validation checks the data needs to pass, then WTForms uses it's | |
widgets to generate the html. | |
A common problem you'll face is "Multiple select fields suck, they are confusing-- | |
how can I show the user a nice list of checkboxes instead?" |
from flask import Flask, render_template_string, request | |
from flask_bootstrap import Bootstrap | |
from jinja2 import Template | |
from flask_wtf import Form | |
from wtforms import StringField | |
from wtforms.validators import DataRequired | |
from flask_sqlalchemy import SQLAlchemy | |
# Build the app along with its extensions and the route |
I hereby claim:
To claim this, I am signing this object:
from flask import Flask, Blueprint | |
app = Flask(__name__) | |
bp = Blueprint("test", __name__) | |
@bp.route("/test/") | |
def test(): | |
return "TEST" | |
app.register_blueprint(bp, subdomain="test") |
gunicorn -c "python:config.gunicorn" "api:create_app()" | |
[2016-10-18 14:01:37 -0400] [3654] [INFO] Starting gunicorn 19.6.0 | |
[2016-10-18 14:01:37 -0400] [3654] [INFO] Listening at: http://0.0.0.0:8000 (3654) | |
[2016-10-18 14:01:37 -0400] [3654] [INFO] Using worker: eventlet | |
[2016-10-18 14:01:37 -0400] [3657] [INFO] Booting worker with pid: 3657 | |
127.0.0.1 - - [18/Oct/2016:14:01:44 -0400] "GET /api/v1/ HTTP/1.1" 200 3101 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36" in 87173µs | |
127.0.0.1 - - [18/Oct/2016:14:01:44 -0400] "GET /socket.io/?EIO=3&transport=polling&t=1476813704788-0 HTTP/1.1" 200 119 "http://localhost:8000/api/v1/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36" in 782µs | |
127.0.0.1 - - [18/Oct/2016:14:01:44 -0400] "POST /socket.io/?EIO=3&transport=polling&t=1476813704809-1&sid=ac7af57072f74aa49d3c92e79bab9f9e HTTP/1.1" 200 2 "http://localhost:8000/ap |
@app.route("/test_session") | |
def write(): | |
session['uid']='my_uid' | |
return session.get('uid') | |
@app.route("/read_session") | |
def read(): | |
return session.get('uid') |
def add_cors_headers(response): | |
response.headers['Access-Control-Allow-Origin'] = '*' | |
if request.method == 'OPTIONS': | |
response.headers['Access-Control-Allow-Methods'] = 'DELETE, GET, POST, PUT' | |
headers = request.headers.get('Access-Control-Request-Headers') | |
if headers: | |
response.headers['Access-Control-Allow-Headers'] = headers | |
return response | |
app.after_request(add_cors_headers) |