I am currently developing an application. this web app has its own domain. when initially created i set up the domain and the registrar using the cname and it succesfully displayed after a couple of hours "this is a flask app..." something like that.
i decided to follow the examples of Mr Grinberg in his book (fully functional on localhost). So i cloned my personal repository to pythonanywhere and ran the following commands.
python manage.py db init
python manage.py db upgrade
python manage.py migrate
every thing is ok so far. and i checked out the mysql database using mysql workbench.
Now comes my issue.
when i run python manage.py runserver
it throws me the following error.
/home/username/.virtualenvs/webapp/local/lib/python2.7/site-packages
/flask_sqlalchemy/__init__.py:800: UserWarning: SQLALCHEMY_TRACK_MODIFICA
TIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.
warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to su
ppress this warning.')
Traceback (most recent call last):
File "manage.py", line 20, in <module>
manager.run()
File "/home/username/.virtualenvs/webapp/local/lib/python2.7/site-packages/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/home/username/.virtualenvs/webapp/local/lib/python2.7/site-packages/flask_script/__init__.py", line 383, in handle
res = handle(*args, **config)
File "/home/username/.virtualenvs/webapp/local/lib/python2.7/site-packages/flask_script/commands.py", line 425, in __call__
**self.server_options)
File "/home/username/.virtualenvs/webapp/local/lib/python2.7/site-packages/flask/app.py", line 843, in run
run_simple(host, port, self, **options)
File "/home/username/.virtualenvs/webapp/local/lib/python2.7/site-packages/werkzeug/serving.py", line 677, in run_simple
s.bind((hostname, port))
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
i tried disabling the wsgi.py file (commenting everything out) still the same.
Things to know:
- i have a paid acount.
- this is the second webapp on pythonanywhere. (the first one is not modeled based on the tutorial and works just fine)
EDIT
i changed the port from 5000 to 9000. and it runs in the console. but i cant visit my site. should i comment out the wsgi file?
currently it looks likes this:
import sys
# # add your project directory to the sys.path
project_home = u'/home/username/e_orders/e_orders'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# # import flask app but need to call it "application" for WSGI to work
from manager import app as application
manage.py
import os
from app import create_app, db
from app.models import User
from flask_script import Manager, Shell, Server
from flask_migrate import Migrate, MigrateCommand
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
manager = Manager(app)
migrate = Migrate(app, db)
def make_shell_context():
return dict(app=app, db=db, User=User)
manager.add_command('shell', Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)
manager.add_command('runserver', Server(port=9000))
if __name__ == '__main__':
manager.run()
EDIT 2
i have the following error with the wsgi configuration above.
errorlog
ImportError: No module named manager
2016-08-04 17:42:39,589 :Error running WSGI application
Traceback (most recent call last):
File "/bin/user_wsgi_wrapper.py", line 154, in __call__
app_iterator = self.app(environ, start_response)
File "/bin/user_wsgi_wrapper.py", line 170, in import_error_application
raise e
ImportError: No module named manager