Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialManish Giri
16,266 PointsHow to manage two python 'apps' running simultaneously?
I was doing the "multiply view" challenge, and decided to try it out on workspace. It already had a python file called "simple_app.py" which had all the code that Kenneth showed us in this series.
In the new file "multiply_view.py" I wrote all the code for the multiply view challenge, but when I ran it(in the workspace), I got this error:
* Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
Traceback (most recent call last):
File "multiply_view.py", line 13, in <module>
app.run(debug=True, port=8000, host='0.0.0.0')
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/flask/app.py", line 772, in r
un
run_simple(host, port, self, **options)
File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/werkzeug/serving.py", line 61
8, in run_simple
test_socket.bind((hostname, port))
OSError: [Errno 98] Address already in use
treehouse:~/workspace$
Most importantly, after this happened, it looks like the cursor is just not moving away from the "console" part of the workspace. Anything I want to type in my file, all happens in the console instead. Things like Ctrl-C or Ctrl-Z aren't working.
Can someone help me understand the two issues.
from flask import Flask
app = Flask(__name__)
@app.route('/multiply')
@app.route('/multiply/<int:term1>/<int:term2>')
@app.route('/multiply/<float:term1>/<float:term2>')
@app.route('/multiply/<float:term1>/<int:term2>')
@app.route('/multiply/<int:term1>/<float:term2>')
def multiply(term1=5, term2=5):
return "{}".format(term1 * term2)
1 Answer
Chris Freeman
Treehouse Moderator 68,457 PointsThe two apps are colliding on the PORT number 8000. Change one of the "app.py" files to use a different port such as 8080. You can see the ports available with Workspaces in the dropdown Preview menu.