Skip to content

Instantly share code, notes, and snippets.

@nenodias
Last active November 22, 2016 11:45
Show Gist options
  • Select an option

  • Save nenodias/f6a0269d27e19f8498de59e9074b6224 to your computer and use it in GitHub Desktop.

Select an option

Save nenodias/f6a0269d27e19f8498de59e9074b6224 to your computer and use it in GitHub Desktop.
Flask example
# -*- coding:utf-8 -*-
'''
(py3) hdias@hdias-SUPPORT:~/Downloads$ pip install flask
(py3) hdias@hdias-SUPPORT:~/Downloads$ pip install gunicorn
Collecting gunicorn
Using cached gunicorn-19.6.0-py2.py3-none-any.whl
Installing collected packages: gunicorn
Successfully installed gunicorn-19.6.0
(py3) hdias@hdias-SUPPORT:~/Downloads$ gunicorn exemplo:app
'''
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/<port>/<value>')
def index(port, value):
try:
retorno = { 'sucesso': True, 'mensagem':'tudo beautiful'}
return jsonify(retorno)
except Exception as e:
print(e)
return '', 500
if __name__ == '__main__':
app.run(debug=True, use_reloader=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment