I am using Flask to build a mobile application. It worked fine before I set up Flask structure for large application. like this http://flask.pocoo.org/docs/patterns/packages/
WSGI worked fine when I had one python file. However, WSGI is not working after I import python files.
Here is directory structure.
/home
/bridge
index.py
apis.wsgi
/apis
__init__.py
settings.py
Index.py
from apis import app
app.run(host='0.0.0.0',debug=True)
apis.wsgi
import sys
sys.path.insert(0,'/home/bridge/apis')
from apis import app as application
init.py
from flask import Flask
app = Flask(__name__)
import apis.settings
settings.py
from flask import Flask
import os
import sys
from flask import render_template, request, jsonify, redirect, url_for, send_file, Response, make_response
@app.route('/apis/settings/aboutus')
def aboutus():
return render_template('settings/aboutus.html')
When I run it after run #python index.py Domain.com/apis/settings/aboutus worked fine.
However, if I turn on WSGI it failed to load the page and showed this error.
Internal Server Error
Of course, I checked error log.
[error] [client 14.63.12.134] mod_wsgi (pid=2138): Exception occurred processing WSGI script '/home/bridge/index.wsgi'.
[error] [client 14.63.12.134] Traceback (most recent call last):
[error] [client 14.63.12.134] File "/home/bridge/index.wsgi", line 3, in <module>
[error] [client 14.63.12.134] from index import app as application
[error] [client 14.63.12.134] File "/home/bridge/index.py", line 2, in <module>
[error] [client 14.63.12.134] app.run(host='0.0.0.0',debug=True)
[error] [client 14.63.12.134] File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 772, in run
[error] [client 14.63.12.134] run_simple(host, port, self, **options)
[error] [client 14.63.12.134] File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 706, in run_simple
[error] [client 14.63.12.134] test_socket.bind((hostname, port))
[error] [client 14.63.12.134] File "/usr/lib/python2.7/socket.py", line 224, in meth
[error] [client 14.63.12.134] return getattr(self._sock,name)(*args)
[error] [client 14.63.12.134] error: [Errno 98] Address already in use
I get these errors.
Can you see what is the problem? Thank you.