I am getting the error ModuleNotFoundError: No module named 'main'. I have a flask application deployed on gcloud.
The build was successful on gcloud. The url is given in the logs. But when i invoke the url, the logs shows the below error
ModuleNotFoundError: No module named 'main'
and i get 502 Bad gateway error
Any help is much appreciated.
Below are the respective files.
requirements.txt
flask flask_socketio flask_caching flask_cors gunicorn
cloudbuild.yaml
Install dependencies
name: 'python:3.11' entrypoint: 'pip' args: ['install', '-r', 'requirements.txt']
name: 'gcr.io/cloud-builders/gcloud' entrypoint: '/bin/sh'
args:
- '-c'
- | gcloud app deploy app.yaml timeout: 1600s
app.yaml
runtime: python311
handlers:
url: /static static_dir: static
url: /.* script: | gunicorn -b :8081 app:app
** app.py **
`from flask import Flask
import sys
import os
from flask_socketio import SocketIO
# Create a Flask application
app = Flask(__name__)
socketio = SocketIO(app)
# Define a route for the homepage
@app.route('/')
def home():
return 'Hello, World! This is the homepage.'
# Define a route for a custom endpoint
@app.route('/about')
def about():
return 'This is the about page.'
if __name__ == '__main__':
host = os.environ.get("HOST", "0.0.0.0")
socketio.run(app, host="0.0.0.0", port=8081)`
I have tried building and deploying on gcloud and I expect to see my flask application running. Any help is much appreciated!