Hi,
I am not sure how to get flask to run on an apache2.
I think my config is already correct.
However, I am not sure about how to Structure my __init__.py, flaskapp.wsgi
This is how my folder structure looks like:
├── flaskapp.wsgi
├── project
│ ├── auth.py
│ ├── __init__.py
│ ├── main.py
│ ├── models.py
│ ├── __pycache__
│ │ ├── auth.cpython-37.pyc
│ │ ├── __init__.cpython-37.pyc
│ │ ├── main.cpython-37.pyc
│ │ └── models.cpython-37.pyc
│ └── templates
│ ├── base.html
│ ├── index.html
│ ├── login.html
│ ├── profile.html
│ └── signup.html
└── setup.py
This my flaskapp.wsgi:
Is it about the code, which runs locally?
My FlaskApp.cnf
I am not sure how to get flask to run on an apache2.
I think my config is already correct.
However, I am not sure about how to Structure my __init__.py, flaskapp.wsgi
This is how my folder structure looks like:
├── flaskapp.wsgi
├── project
│ ├── auth.py
│ ├── __init__.py
│ ├── main.py
│ ├── models.py
│ ├── __pycache__
│ │ ├── auth.cpython-37.pyc
│ │ ├── __init__.cpython-37.pyc
│ │ ├── main.cpython-37.pyc
│ │ └── models.cpython-37.pyc
│ └── templates
│ ├── base.html
│ ├── index.html
│ ├── login.html
│ ├── profile.html
│ └── signup.html
└── setup.py
This my flaskapp.wsgi:
#!/usr/bin/python3 import sys import logging logging.basicConfig(stream=sys.stderr) sys.path.insert(0,"/var/www/FlaskApp/MyApp") from project import create_app app = create_app() if __name__ == "__main__": app.run()and this is my __init__.py:
from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_login import LoginManager db = SQLAlchemy() def create_app(): app = Flask(__name__) app.config['SECRET_KEY'] = 'secretkeyforyou' app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+mysqlconnector://{user}:{password}@{server}/{database}'.format( user='root', password='PYTHON-FORUM', server='localhost', database='USERS') db = SQLAlchemy(app) db.init_app(app) login_manager = LoginManager() login_manager.login_view = 'auth.login' login_manager.init_app(app) from .models import User @login_manager.user_loader def load_user(user_id): # since the user_id is just the primary key of our user table, use it in the query for the user return User.query.get(int(user_id)) # blueprint for auth routes in our app from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint) # blueprint for non-auth parts of app from .main import main as main_blueprint app.register_blueprint(main_blueprint) return appWhat is it that I am doing wrong?
Is it about the code, which runs locally?
My FlaskApp.cnf
<VirtualHost *:80> ServerName rosenheim-cainsdorf.de ServerAdmin [email protected] WSGIScriptAlias / /var/www/FlaskApp/MyApp/flaskapp.wsgi <Directory /var/www/FlaskApp/MyApp/> Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>