Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

420
Visualizações
WSGI file not loading Python Flask file on Apache 2.4 on Windows Server 2012

I'm trying to run a Flask script that queries an SQLite database and displays a Rest API only for inside the network. It is going to be served on Windows Server 2012 running Apache 2.4 with mod_wsgi. I'm also using Python 3.7.

The error I'm getting in the error log is:

File "D:/sites/cifsearch/website/web.wsgi", line 7, in <module>\r, referer: 
     http://IP Address/  from app.py import app as application\r, referer: 
     http://IP Address/  ModuleNotFoundError: No module named 'app'\r, referer: http://IP Address/

web.wsgi is on the same directory as app.py

This is what I have written on web.wsgi. I copied and pasted this from what I could find on google as I'm still very new to this.

import sys
import logging

logging.basicConfig (stream=sys.stderr)
sys.path.insert(0,'/')

from app.py import app as application

I also commented out:

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

in app.py as per this site: https://flask.palletsprojects.com/en/1.1.x/deploying/mod_wsgi/. But I don't think the request is even getting that far. I'm suspecting, it's probably path related or permissions?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Your application is not set up as a package, so the import in your wsgi code gives you the ModuleNotFoundError.

Put your application in a directory called e.g. myapp and add an __init__.py file to the directory containing

from .app import app

to make it a package.

Your directory structure should look like this:

web.wsgi
myapp/
    app.py
    __init__.py

Then change your import line in the wsgi file to

from myapp import app as application
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda