0

I have tried with all possible approaches on different websites. But have no luck.

Currently I am following - Run multiple independent Flask apps in Ubuntu

I have two flask application

/var/www/html/myapps/flaskapp2
/var/www/html/myapps/flaskapp

Both having python file and wsgi files.

/var/www/html/myapps/flaskapp2/flaskapp2.py

from flask import Flask
app = Flask(__name__)
@app.route("/newflask")
def hello():
    return "Hello,welcome to flask website!"
if __name__ == "__main__":
    app.run()

/var/www/html/myapps/flaskapp2/flaskapp2.wsgi

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/html/myapps/flaskapp2/")

from flaskapp2 import app as application

and conf file

<VirtualHost *:80>
                ServerName http://IP
                ServerAlias IP
                ServerAdmin [email protected]

                WSGIDaemonProcess app1 user=karim group=karim threads=5 python-home=/var/www/html/myapps/flaskapp:/home/k/projects_r/venv_3.7/lib/python3.7/site-packages
                WSGIScriptAlias /app1 /var/www/html/myapps/flaskapp/flaskapp.wsgi
                <Directory /var/www/html/myapps/flaskapp>
                        WSGIApplicationGroup app1
                        WSGIProcessGroup app1
                        Order allow,deny
                        Allow from all
                </Directory>


                WSGIDaemonProcess app2 user=karim group=karim threads=5 python-home=/var/www/html/myapps/flaskapp2:/home/k/projects_r/venv_3.7/lib/python3.7/site-packages
                WSGIScriptAlias /app2 /var/www/html/myapps/flaskapp2/flaskapp2.wsgi
                <Directory /var/www/html/myapps/flaskapp2>
                        WSGIApplicationGroup app2
                        WSGIProcessGroup app2
                        Order allow,deny
                        Allow from all
                </Directory>

                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

When I try to open

http://IP/myapps/flaskapp/flask
http://IP/myapps/flaskapp2/newflask

It gives me

Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

UPDATE 1

only this app.conf works at IP/flask

<VirtualHost *:80>
                ServerName http://IP
                ServerAlias IP
                ServerAdmin [email protected]
                WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi
                <Directory /var/www/html/flaskapp>
                        Order allow,deny
                        Allow from all
                </Directory>

                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
8
  • What errors are you getting? We need more information than "have no luck" i'm afraid. Commented Apr 18, 2019 at 6:34
  • @Ewan: Yes, just updated Commented Apr 18, 2019 at 6:35
  • please send full traceback of your error Commented Apr 18, 2019 at 6:37
  • @nihal: Where do I get it Commented Apr 18, 2019 at 6:37
  • in python error Commented Apr 18, 2019 at 6:37

1 Answer 1

2

It looks to me that you are using the wrong URLs. Your WSGIScriptAlias is set to listen on /app1 and /app2 respectively so I would first try accessing:

http://IP/app1
http://IP/app2

and check the WSGIScriptAlias documentation

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

1 Comment

Thanks @Ewan: but this also ends up with same error message. I tried one you suggested and also http://IP/app1/flask http://IP/app2/newflask as per the route I have given

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.