Last active
November 22, 2016 11:45
-
-
Save nenodias/f6a0269d27e19f8498de59e9074b6224 to your computer and use it in GitHub Desktop.
Flask example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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