1

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 [email protected]
                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 [email protected]
                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?

9
  • your apps are running on the same port, have you tried changing ports for each app in the app.run(port=xxxx)? Commented Apr 13, 2019 at 10:18
  • Yes, I tried giving different port in app.run() but still same issue. At a time only one application runs Commented Apr 13, 2019 at 12:36
  • However, when you use <VirtualHost *:80> , it seems you are overriding the default port for your apps. which means all your apps are running on port 80. Have you tried with different ports on the config file ? Commented Apr 13, 2019 at 12:43
  • yes but please give some different port example Commented Apr 13, 2019 at 13:20
  • try ports from 5005 to 5010 to avoid any conflicts with anything you might have already ran. you can just config each instance like : <VirtualHost *:5005> and so one .. Commented Apr 13, 2019 at 13:22

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.