1

I'm trying to deploy a simple hello world flask app on a linux server (Ubuntu 18.04.3). I'm logged into the linux box as bobtheuser. However, when I access the , I only see the contents "Index of/" listing the contents of /var/www/html/, i.e. the flask webapp isn't starting up.

flask app setup The app directory is setup like so:

'/var/www/html/helloflask
├── __init__.py
├── my_flask_app.py
├── my_flask_app.wsgi

my_flask_app.py

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello world! Hello Apache2 webserver!"

if __name__ == "__main__":
    app.run()

my_flask_app.wsgi

#!/usr/bin/env python3

import logging
import sys
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, '/var/www/html/helloflask/')
from my_flask_app import app as application
application.secret_key = 'helloflask-sk'

/etc/apache2/sites-available/helloflask.conf

<VirtualHost *:80>
     # Add machine's IP address (use ifconfig command)
     ServerName 128.250.89.117
     # Give an alias to to start your website url with
     WSGIScriptAlias / /var/www/html/helloflask/my_flask_app.wsgi
     <Directory /var/www/html/helloflask>
     # set permissions as per apache2.conf file
            Options FollowSymLinks
            AllowOverride None
            Require all granted
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error.log
     LogLevel warn
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.