I have multiple flask application in var/www/html
like var/www/html/website
, var/www/html/summary
, var/www/html/sentiment
Once I run all application successfully.
Then I added one more application for which I created conf file and restarted server.
After that all application stopped working, only var/www/html/sentiment
opens.
I checked code in python, wsgi and conf file for other application is same as it is in sentiment.
Sentiment application code
flaskapp.py
from flask import Flask
app = Flask(__name__)
@app.route('/sentiment')
def hello_world():
return 'Hello from Sentiment!'
if __name__ == '__main__':
app.run()
flaskapp.wsgi
import sys
sys.path.insert(0, '/var/www/html/sentiment/')
from flaskapp import app as application
conf file - /etc/apache2/sites-available/sentiment.conf
<VirtualHost *:80>
ServerName IP
ServerAdmin admin@mywebsite.com
WSGIScriptAlias / /var/www/html/sentiment/flaskapp.wsgi
<Directory /var/www/html/sentiment/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Summary application code flaskapp.y
from flask import Flask
app = Flask(__name__)
@app.route('/summary')
def hello_world():
return 'Hello from Summary!'
if __name__ == '__main__':
app.run()
flaskapp.wsgi
import sys
sys.path.insert(0, '/var/www/html/summary/')
from flaskapp import app as application
/etc/apache2/sites-available/summary.conf
<VirtualHost *:80>
ServerName IP
ServerAdmin admin@mywebsite.com
WSGIScriptAlias / /var/www/html/summary/flaskapp.wsgi
<Directory /var/www/html/summary/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Still when I open ip/sentiment it works but ip/summary gives
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
Any suggestion for this?
The issue is with your WSGIScriptAlias name.
/
points to everything in the directory.
Give unique alias names to all applications.
Example:
Change /
to /app1
for WSGIScriptAlias
Change /
to /app2
for WSGIScriptAlias
in both the files.
Restart the server then.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.