Flask app deployed on G Cloud but when the URL is hit, it returns a 404

Hi everyone,

I have successfully deployed on Flask application on Gcloud (at least there are no errors within the build logs) however, when I am trying to access the deployed URL, I am getting the following error:

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

It has been two days, I am stuck with this issue and any help will be really appreciated.

my app.yaml:

runtime: custom
env: flex

resources:
cpu: 4
memory_gb: 16
disk_size_gb: 30
manual_scaling:
instances: 1

entrypoint: gunicorn -b :$PORT app:app

Dockerfile:

Use an official base image from Docker Hub

FROM python:3.12

Set the working directory inside the container

WORKDIR /prod

Copy the local contents into the container at /app

COPY . /prod

Install dependencies (if needed) using pip or package manager

RUN pip install -r requirements.txt

Expose the port on which the application will run

EXPOSE 8080

CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 app:app

and my app.py is :

from flask import Flask, request, jsonify
from flask_cors import CORS
from querying import answer_query
app = Flask(name)
CORS(app)

@app.route(‘/ask’, methods=[‘GET’])
def ask():
query = request.args.get(‘query’)
if not query:
return jsonify({“error”: “No query provided”}), 400

response = answer_query(query)
return jsonify(response)

if name == ‘main’:
app.run(host = ‘0.0.0.0’, port = 8080, debug=True)

Please help
Thanks

Hi @shivasmic

The GAE Flask apps that I’m familiar with are more along the lines of this.

However, it seems to me that unless you are requesting this page:

https://<your-project-id>.appspot.com/ask

any other page request to your app will get NOT FOUND (404) as a response.

Is that the page you’re requesting after deploying? Because I don’t see a route even for a homepage in your code.

Michael