I can't get redirect to work on netlify despite the app working locally

My site name is https://adorable-flan-4059dd.netlify.app with a custom domain name - tragpt.com.

Although my site is deployed, the response from the app does not redirect properly and results in a page not found error. Hence, only the home page works.


10:54:43 PM: build-image version: 6fd4b129abc97418b4cd2d48c553dd4a014a6965 (focal)
10:54:43 PM: buildbot version: 6fd4b129abc97418b4cd2d48c553dd4a014a6965
10:54:43 PM: Fetching cached dependencies
10:54:43 PM: Starting to download cache of 83.8MB
10:54:44 PM: Finished downloading cache in 922ms
10:54:44 PM: Starting to extract cache
10:54:44 PM: Finished extracting cache in 353ms
10:54:44 PM: Finished fetching cache in 1.323s
10:54:44 PM: Starting to prepare the repo for build
10:54:44 PM: Preparing Git Reference refs/heads/main
10:54:45 PM: Parsing package.json dependencies
10:54:46 PM: Starting build script
10:54:46 PM: Installing dependencies
10:54:46 PM: Python version set to 3.8
10:54:46 PM: Started restoring cached Node.js version
10:54:47 PM: Finished restoring cached Node.js version
10:54:47 PM: v16.19.0 is already installed.
10:54:47 PM: Now using node v16.19.0 (npm v8.19.3)
10:54:47 PM: Enabling Node.js Corepack
10:54:48 PM: Started restoring cached build plugins
10:54:48 PM: Finished restoring cached build plugins
10:54:48 PM: Attempting Ruby version 2.7.2, read from environment
10:54:48 PM: Using Ruby version 2.7.2
10:54:48 PM: Using PHP version 8.0
10:54:48 PM: Installing pip dependencies
10:54:48 PM: Started restoring cached pip cache
10:54:48 PM: Finished restoring cached pip cache
10:54:49 PM: Collecting autopep8==1.6.0
10:54:49 PM: Using cached autopep8-1.6.0-py2.py3-none-any.whl (45 kB)
10:54:49 PM: Collecting certifi==2021.10.8
10:54:49 PM: Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
10:54:49 PM: Collecting charset-normalizer==2.0.7
10:54:49 PM: Using cached charset_normalizer-2.0.7-py3-none-any.whl (38 kB)
10:54:49 PM: Collecting click==8.0.3
10:54:49 PM: Using cached click-8.0.3-py3-none-any.whl (97 kB)
10:54:50 PM: Collecting et-xmlfile==1.1.0
10:54:50 PM: Using cached et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
10:54:50 PM: Collecting Flask==2.0.2
10:54:50 PM: Using cached Flask-2.0.2-py3-none-any.whl (95 kB)
10:54:50 PM: Collecting Frozen-Flask==0.18
10:54:50 PM: Using cached Frozen_Flask-0.18-py3-none-any.whl (21 kB)
10:54:50 PM: Collecting idna==3.3
10:54:50 PM: Using cached idna-3.3-py3-none-any.whl (61 kB)
10:54:50 PM: Collecting itsdangerous==2.0.1
10:54:50 PM: Using cached itsdangerous-2.0.1-py3-none-any.whl (18 kB)
10:54:50 PM: Collecting Jinja2==3.0.2
10:54:50 PM: Using cached Jinja2-3.0.2-py3-none-any.whl (133 kB)
10:54:50 PM: Collecting MarkupSafe==2.0.1
10:54:50 PM: Using cached MarkupSafe-2.0.1-cp38-cp38-manylinux2010_x86_64.whl (30 kB)
10:54:50 PM: Collecting numpy==1.21.3
10:54:50 PM: Using cached numpy-1.21.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.7 MB)
10:54:50 PM: Processing /opt/buildhome/.cache/pip/wheels/a0/1c/c6/e258dd9f51667f810902504b9bdeeeb4f2298f72effc65bc2c/openai-0.19.0-py3-none-any.whl
10:54:51 PM: Collecting openpyxl==3.0.9
10:54:51 PM: Using cached openpyxl-3.0.9-py2.py3-none-any.whl (242 kB)
10:54:51 PM: Collecting pandas==1.3.4
10:54:51 PM: Using cached pandas-1.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB)
10:54:51 PM: Collecting pandas-stubs==
10:54:51 PM: Using cached pandas_stubs- (159 kB)
10:54:51 PM: Collecting pycodestyle==2.8.0
10:54:51 PM: Using cached pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)
10:54:51 PM: Collecting python-dateutil==2.8.2
10:54:51 PM: Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
10:54:51 PM: Collecting python-dotenv==0.19.2
10:54:51 PM: Using cached python_dotenv-0.19.2-py2.py3-none-any.whl (17 kB)
10:54:51 PM: Collecting pytz==2021.3
10:54:51 PM: Using cached pytz-2021.3-py2.py3-none-any.whl (503 kB)
10:54:52 PM: Collecting requests==2.26.0
10:54:52 PM: Using cached requests-2.26.0-py2.py3-none-any.whl (62 kB)
10:54:52 PM: Collecting six==1.16.0
10:54:52 PM: Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
10:54:52 PM: Collecting toml==0.10.2
10:54:52 PM: Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
10:54:52 PM: Collecting tqdm==4.62.3
10:54:52 PM: Using cached tqdm-4.62.3-py2.py3-none-any.whl (76 kB)
10:54:52 PM: Collecting urllib3==1.26.7
10:54:52 PM: Using cached urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
10:54:52 PM: Collecting Werkzeug==2.0.2
10:54:52 PM: Using cached Werkzeug-2.0.2-py3-none-any.whl (288 kB)
10:54:52 PM: Installing collected packages: toml, pycodestyle, autopep8, certifi, charset-normalizer, click, et-xmlfile, Werkzeug, MarkupSafe, Jinja2, itsdangerous, Flask, Frozen-Flask, idna, numpy, openpyxl, pandas-stubs, urllib3, requests, tqdm, six, python-dateutil, pytz, pandas, openai, python-dotenv
10:54:52 PM: Attempting uninstall: certifi
10:54:52 PM: Found existing installation: certifi 2022.12.7
10:54:52 PM: Uninstalling certifi-2022.12.7:
10:54:52 PM: Successfully uninstalled certifi-2022.12.7
10:54:57 PM: Successfully installed Flask-2.0.2 Frozen-Flask-0.18 Jinja2-3.0.2 MarkupSafe-2.0.1 Werkzeug-2.0.2 autopep8-1.6.0 certifi-2021.10.8 charset-normalizer-2.0.7 click-8.0.3 et-xmlfile-1.1.0 idna-3.3 itsdangerous-2.0.1 numpy-1.21.3 openai-0.19.0 openpyxl-3.0.9 pandas-1.3.4 pandas-stubs- pycodestyle-2.8.0 python-dateutil-2.8.2 python-dotenv-0.19.2 pytz-2021.3 requests-2.26.0 six-1.16.0 toml-0.10.2 tqdm-4.62.3 urllib3-1.26.7
10:54:57 PM: Pip dependencies installed
10:54:57 PM: Started restoring cached go cache
10:54:57 PM: Finished restoring cached go cache
10:54:57 PM: go version go1.19.5 linux/amd64
10:54:57 PM: Detected 0 framework(s)
10:54:57 PM: Installing missing commands
10:54:57 PM: Verify run directory
10:54:57 PM: Section completed: initializing
10:54:59 PM: ​
10:54:59 PM: Netlify Build
10:54:59 PM: ────────────────────────────────────────────────────────────────
10:54:59 PM: ​
10:54:59 PM: ❯ Version
10:54:59 PM: @netlify/build 29.5.4
10:54:59 PM: ​
10:54:59 PM: ❯ Flags
10:54:59 PM: baseRelDir: true
10:54:59 PM: Starting post processing
10:54:59 PM: buildId: 63e08810fdbe9a000872aa18
10:54:59 PM: deployId: 63e08810fdbe9a000872aa1a
10:54:59 PM: ​
10:54:59 PM: Post processing - HTML
10:54:59 PM: ❯ Current directory
10:54:59 PM: /opt/build/repo
10:54:59 PM: ​
10:54:59 PM: ❯ Config file
10:54:59 PM: Post processing - header rules
10:54:59 PM: /opt/build/repo/netlify.toml
10:54:59 PM: ​
10:54:59 PM: ❯ Context
10:55:00 PM: Post processing - redirect rules
10:54:59 PM: production
10:54:59 PM: ​
10:54:59 PM: 1. Build command from Netlify app
10:54:59 PM: ────────────────────────────────────────────────────────────────
10:55:00 PM: Post processing done
10:54:59 PM: ​
10:54:59 PM: $ python build.py
10:54:59 PM: ​
10:55:00 PM: Section completed: postprocessing
10:54:59 PM: (build.command completed in 307ms)
10:54:59 PM: ​
10:54:59 PM: 2. Deploy site
10:54:59 PM: ────────────────────────────────────────────────────────────────
10:54:59 PM: ​
10:54:59 PM: Starting to deploy site from β€˜build’
10:54:59 PM: Calculating files to upload
10:54:59 PM: 0 new files to upload
10:54:59 PM: 0 new functions to upload
10:54:59 PM: Section completed: deploying
10:54:59 PM: Site deploy was successfully initiated
10:54:59 PM: ​
10:54:59 PM: (Deploy site completed in 55ms)
10:54:59 PM: ​
10:54:59 PM: Netlify Build Complete
10:55:00 PM: Site is live :sparkles:
10:54:59 PM: ────────────────────────────────────────────────────────────────
10:54:59 PM: ​
10:54:59 PM: (Netlify Build completed in 406ms)
10:54:59 PM: Caching artifacts
10:54:59 PM: Started saving build plugins
10:54:59 PM: Finished saving build plugins
10:54:59 PM: Started saving pip cache
10:54:59 PM: Finished saving pip cache
10:54:59 PM: Started saving emacs cask dependencies
10:54:59 PM: Finished saving emacs cask dependencies
10:54:59 PM: Started saving maven dependencies
10:54:59 PM: Finished saving maven dependencies
10:54:59 PM: Started saving boot dependencies
10:55:00 PM: Finished saving boot dependencies
10:55:00 PM: Started saving rust rustup cache
10:55:00 PM: Finished saving rust rustup cache
10:55:00 PM: Started saving go dependencies
10:55:00 PM: Finished saving go dependencies
10:55:00 PM: Build script success
10:55:00 PM: Section completed: building
10:55:00 PM: Uploading Cache of size 83.9MB
10:55:01 PM: Section completed: cleanup
10:55:01 PM: Finished processing build request in 17.8s

@Abi2023 Are you able to link to the repository?

Hi Nathan,
Yes, this is the repo link: https://github.com/abbey2017/travelgpt


@Abi2023 If you’re talking about this redirect…

  from = "/*"
  to = "/index.html"
  status = 200

Then it is working corectly, which you can confirm by going to any url, for example:

If you’re talking about how your app behaves when the user presses the Generate places button, that will be due to the form having a method of post…

If you change it to get you will at least see the submitted value as a query string parameter in the url.

The results are not showing after the generate places is clicked. I am not sure I understand the suggestion.

@Abi2023 When the user enters the value into the input and hits submit, and the form does a POST to the /, what do you believe is receiving the posted value and responding?

Because if it’s this code in your app.py:

@app.route("/", methods=("GET", "POST"))
def index():
    if request.method == "POST":

Then you’ve misunderstood the type of hosting that is available with Netlify.

There’s no runtime server with python, or any of the other languages available.

Your build should execute, produce a static output that can be deployed to CDN, and then any runtime functionality needs to be achieved either via Serverless Functions or a server that you host elsewhere.

Ok, thanks. I will look at the GET method.

@Abi2023 See my updated message above that explains why you’re not seeing what you expect to see.