Answer the question
In order to leave comments, you need to log in
Why is the object not being imported from module ModuleNotFoundError: No module named 'app'?
Hello.
I have such a project folder structure
in wcgi.py, I register the connection of the server1 object from app.main
from app.main1 import server1
if __name__ == "__main__":
server1.run(host='0.0.0.0', port=8118)
from flask import Flask
from flask import request, jsonify
from random import sample
server1 = Flask(__name__)
def run_request():
index = int(request.json['index'])
list = ['red', 'green', 'blue', 'yellow', 'black']
return list[index]
@server1.route('/', methods=['GET', 'POST'])
def hello_world():
if request.method == 'GET':
return 'The model is up and running. Send a POST request'
else:
return run_request()
app$ gunicorn -w 1 -b 0.0.0.0:8118 wsgi:server
File "/home/drno/IdeaProjects/inclouds/backend/app/wsgi.py", line 1, in <module>
from app.main1 import server1
ModuleNotFoundError: No module named 'app'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question