Let’s Bring Etiquette to User Testing
medium.com1 pointsby glimcat0 comments
from requests_oauthlib import OAuth1Session
import json
keys = json.loads(open(keyfile).read())
# {"TWITTER_CONSUMER_KEY": "blah_blah_blah",
# "TWITTER_CONSUMER_SECRET": "blah_blah_blah",
# "TWITTER_ACCESS_TOKEN": "blah_blah_blah",
# "TWITTER_ACCESS_TOKEN_SECRET": "blah_blah_blah",}
def twitter():
return OAuth1Session(keys['TWITTER_CONSUMER_KEY'],
client_secret=keys['TWITTER_CONSUMER_SECRET'],
resource_owner_key=keys['TWITTER_ACCESS_TOKEN'],
resource_owner_secret=keys['TWITTER_ACCESS_TOKEN_SECRET'])
def tweet(status, reply_to=None):
endpoint = 'https://api.twitter.com/1.1/statuses/update.json'
data = {'status': status}
r = twitter().post(endpoint, data=data)
return r.status_code
def tweet_with_image(status, imgfile, reply_to=None):
endpoint = 'https://api.twitter.com/1.1/statuses/update_with_media.json'
data = {'status': status}
if reply_to is not None:
data.update({'in_reply_to_status_id': reply_to})
r = twitter().post(endpoint, data=data, files={'media[]': open(imgfile, 'rb').read()})
return r.status_code from flask import render_template
from flask_wtf import Form
from wtforms import TextField
from wtforms.validators import DataRequired
class ScriptForm(Form):
param1 = TextField('Param1', validators=[DataRequired()])
param2 = TextField('Param2', validators=[DataRequired()])
param3 = TextField('Param3', validators=[DataRequired()])
@app.route('/foo-script', methods=('GET', 'POST'))
def foo_script():
form = ScriptForm()
if form.validate_on_submit():
do_stuff(form.data)
else:
return render_template('foo_script.html', form=form)
def do_stuff(data):
for key in data:
print '%s: %s' % (key, data[key])
foo_script.html {% extends "base.html" %}
{% block content %}
<h3>Run foo script:</h3>
<form method="POST" action="{{ url_for('foo_script') }}">
{{ form.hidden_tag() }}
{{ form.param1.label }} {{ form.param1 }}
{{ form.param2.label }} {{ form.param2 }}
{{ form.param3.label }} {{ form.param3 }}
<input type="submit" value="Run foo script">
</form>
{% endblock %}
base.html <!DOCTYPE html>
<html lang="en">
<head>
<title>FooCorp Script Service</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
app.py from flask import Flask
app = Flask(__name__)
app.config.from_pyfile('config.py')
import foo_script, bar_script, baz_script
config.py # You need this for CSRF protection & cookie signing
SECRET_KEY = randomly_generated_secret_key
You should also look into Flask's blueprints at some point if it keeps growing. But it's not really essential, just another tool to help you keep projects organized. Flask is mostly "do whatever makes sense in your specific case" rather than imposing many global constraints on structure.
When that kind of response comes from the site's moderator, I really don't see the level of toxicity improving any time soon.
It's likely statistically factual, but in context it's just another of the "mean, stupid things" that Paul Graham called you out as being here to address. And you appear to have done nothing to investigate whether the previous user's post was factually correct before slinging personal accusations.
If this gets me hellbanned too, so be it. Conversation and community on this site is a toxic mess that leaves people afraid to post anything. The main good thing is following users like patio11 and tptacek.
http://blog.ycombinator.com/meet-the-people-taking-over-hack...