mirror of
https://github.com/not-kennethreitz/typy.io.git
synced 2026-06-05 07:06:12 +00:00
fix indentation
This commit is contained in:
@@ -34,61 +34,63 @@ sentry = Sentry(app, dsn=config('SENTRY_DSN'))
|
||||
store = bucketstore.get('typy', create=True)
|
||||
store_total = len(store.list())
|
||||
|
||||
|
||||
@app.after_request
|
||||
def apply_kr_hello(response):
|
||||
"""Adds some headers to all responses."""
|
||||
|
||||
# Made by Kenneth Reitz.
|
||||
if 'MADE_BY' in os.environ:
|
||||
response.headers["X-Was-Here"] = os.environ.get('MADE_BY')
|
||||
|
||||
# Powered by Flask.
|
||||
response.headers["X-Powered-By"] = os.environ.get('POWERED_BY')
|
||||
return response
|
||||
"""Adds some headers to all responses."""
|
||||
|
||||
# Made by Kenneth Reitz.
|
||||
if 'MADE_BY' in os.environ:
|
||||
response.headers["X-Was-Here"] = os.environ.get('MADE_BY')
|
||||
|
||||
# Powered by Flask.
|
||||
response.headers["X-Powered-By"] = os.environ.get('POWERED_BY')
|
||||
return response
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def type_away(fork=None):
|
||||
if fork:
|
||||
doc = store[fork]
|
||||
else:
|
||||
doc = None
|
||||
|
||||
return render_template('write.html', total=store_total, seed=doc)
|
||||
if fork:
|
||||
doc = store[fork]
|
||||
else:
|
||||
doc = None
|
||||
|
||||
return render_template('write.html', total=store_total, seed=doc)
|
||||
|
||||
|
||||
@app.route('/raw')
|
||||
def document_list():
|
||||
return jsonify({'documents': store.list()})
|
||||
return jsonify({'documents': store.list()})
|
||||
|
||||
|
||||
@app.route('/', methods=['POST'])
|
||||
def put_type():
|
||||
doc = request.form['document']
|
||||
doc = request.form['document']
|
||||
|
||||
# Sha256 of document.
|
||||
sha = hashlib.sha256(doc).hexdigest()
|
||||
# Sha256 of document.
|
||||
sha = hashlib.sha256(doc).hexdigest()
|
||||
|
||||
# Store the document.
|
||||
store[sha] = doc
|
||||
|
||||
return redirect(url_for('get_type', hash=sha))
|
||||
# Store the document.
|
||||
store[sha] = doc
|
||||
|
||||
return redirect(url_for('get_type', hash=sha))
|
||||
|
||||
|
||||
@app.route('/<hash>')
|
||||
def get_type(hash):
|
||||
doc = mistune.markdown(store[hash])
|
||||
return render_template('doc.html', doc=doc, hash=hash, total=store_total)
|
||||
doc = mistune.markdown(store[hash])
|
||||
return render_template('doc.html', doc=doc, hash=hash, total=store_total)
|
||||
|
||||
|
||||
@app.route('/<hash>/raw')
|
||||
def get_raw_type(hash):
|
||||
return Response(store[hash], mimetype='text/plain')
|
||||
return Response(store[hash], mimetype='text/plain')
|
||||
|
||||
|
||||
@app.route('/<hash>/fork')
|
||||
def fork_type(hash):
|
||||
return type_away(fork=hash)
|
||||
|
||||
return type_away(fork=hash)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
app.run()
|
||||
Reference in New Issue
Block a user