├── .gitignore ├── Procfile ├── requirements.txt ├── app.json ├── README.md ├── LICENSE └── question.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.gz 2 | env 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn question:app --log-file=- 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | asjson==1.2.1 2 | Flask==0.10.1 3 | gunicorn==19.3.0 4 | itsdangerous==0.24 5 | Jinja2==2.8 6 | jsondict==1.2 7 | MarkupSafe==0.23 8 | requests==2.7.0 9 | shortuuid==0.4.2 10 | Werkzeug==0.10. -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "question", 3 | "description": "A Flask web server for quickly asking someone a question.", 4 | "repository": "https://github.com/blha303/question", 5 | "website": "https://github.com/blha303/question", 6 | "keywords": ["http", "rest", "API", "python", "flask"] 7 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Question 2 | ======== 3 | 4 | [](https://heroku.com/deploy) 5 | 6 | A Flask web server for quickly asking someone a question. Uses [Airgram](http://www.airgramapp.com) for push notification functionality, so users need to make accounts there. 7 | 8 | Currently backend JSON api only. Feel free to implement your own frontend around the API using your own instance. 9 | 10 | The lines starting with "Question from" are sent first, at the same time. The user swipes or selects the relevant option, and a reply is sent to the user indicating their choice. In the below example, I used my own username for both. 11 | 12 |  13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Steven Smith (blha303) 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /question.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | #Copyright (c) 2015, Steven Smith (blha303) 3 | #All rights reserved. 4 | # 5 | #Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 | # 7 | #1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 | # 9 | #2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 10 | # 11 | #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | 13 | #Updates at https://github.com/blha303/question 14 | 15 | from flask import Flask, request, jsonify, make_response 16 | import json, requests, logging, time, jsondict, gzip, shortuuid 17 | 18 | URL = "http://b303.me:7456" 19 | app = Flask(__name__) 20 | 21 | USERS = jsondict.JsonDict("users.json.gz", compress=True, autosave=True) 22 | PENDING = jsondict.JsonDict("pending.json.gz", compress=True, autosave=True) 23 | VERIFY = jsondict.JsonDict("verify.json.gz", compress=True, autosave=True) 24 | 25 | @app.errorhandler(Exception) 26 | def error_handler(e): 27 | try: 28 | code = e.code 29 | except AttributeError: 30 | code = 500 31 | return jsonify(error=code, text=str(e)), code 32 | 33 | def gen_html(header, body=""): 34 | return "