Contact Systems Misc |
jdash@ix-xenial: ~ 16$ pyvenv flask jdash@ix-xenial: ~ 17$ source flask/bin/activate (flask) jdash@ix-xenial: ~ 18$ pip install --upgrade pip Collecting pip Using cached pip-9.0.1-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 8.1.1 Uninstalling pip-8.1.1: Successfully uninstalled pip-8.1.1 Successfully installed pip-9.0.1 (flask) jdash@ix-xenial: ~ 20$ pip install flask Requirement already satisfied: flask in ./flask/lib/python3.5/site-packages Requirement already satisfied: Jinja2>=2.4 in ./flask/lib/python3.5/site-packages (from flask) Requirement already satisfied: Werkzeug>=0.7 in ./flask/lib/python3.5/site-packages (from flask) Requirement already satisfied: click>=2.0 in ./flask/lib/python3.5/site-packages (from flask) Requirement already satisfied: itsdangerous>=0.21 in ./flask/lib/python3.5/site-packages (from flask) Requirement already satisfied: MarkupSafe in ./flask/lib/python3.5/site-packages (from Jinja2>=2.4->flask) (flask) jdash@ix-xenial: ~ 22$ cat flask_hello.py from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello to the World of Flask!' if __name__ == '__main__': app.run(host='128.223.4.35', port=5000, debug=True) (flask) jdash@ix-xenial: ~ 24$ python flask_hello.py Traceback (most recent call last): File "flask_hello.py", line 9, in <module> app.run(host='128.223.4.35', port=5000, debug=True) File "/home/users/jdash/flask/lib/python3.4/site-packages/flask/app.py", line 772, in run run_simple(host, port, self, **options) File "/home/users/jdash/flask/lib/python3.4/site-packages/werkzeug/serving.py", line 677, in run_simple s.bind((hostname, port)) OSError: [Errno 98] Address already in use The port specified in flask_hello.py, port 5000, is already in use on ix. So I edited flask_hello.py and changed the port to 5555. (flask2) jdash@ix-xenial: ~ 28$ emacs -nw flask_hello.py Then I can try starting it again and it works on port 5555. (flask2) jdash@ix-xenial: ~ 30$ python flask_hello.py * Running on http://128.223.4.35:5555/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger pin code: 230-371-362 128.223.4.86 - - [09/May/2016 08:50:55] "GET / HTTP/1.1" 200 - 128.223.4.86 - - [09/May/2016 08:50:55] "GET /favicon.ico HTTP/1.1" 404 - ^Z [1]+ Stopped python flask_hello.py (flask) jdash@ix-xenial: ~ 32$ bg [1]+ python flask_hello.py & Then I used a web browser to test and here I tried using curl. (flask) jdash@ix-xenial: ~ 34$ curl http://128.223.4.35:5555/ 128.223.4.35 - - [09/May/2016 08:51:05] "GET / HTTP/1.1" 200 - Hello to the World of Flask! (flask) jdash@ix-xenial: ~ 36$ deactivate jdash@ix-trusty: ~ 37$ References
|