title: Flask + React App Fails When Deployed to Heroku
body: <p>I am trying to deploy a simple flask + react project to heroku. I am using gunicorn. The application works when deployed locally but fails on Heroku. The issue lies within trying to serve static files from the build folder but I cannot find out what the problem is.</p>
  <p>Here is the relevant code</p>
  <pre><code>#app.py
  
  app = Flask(__name__,
              static_folder='build',
              static_url_path='/')
  
  @app.route('/')
  def serve():
          return app.send_static_file('index.html')
  </code></pre>
  <p>Heroku logs:</p>
  <pre><code>2020-12-16T12:04:52.431434+00:00 app[web.1]: [2020-12-16 12:04:52,429] ERROR in app: Exception on / [GET]
  2020-12-16T12:04:52.431438+00:00 app[web.1]: Traceback (most recent call last):
  2020-12-16T12:04:52.431438+00:00 app[web.1]: File &quot;/app/.heroku/python/lib/python3.6/site-packages/flask/app.py&quot;, line 1950, in full_dispatch_request
  2020-12-16T12:04:52.431439+00:00 app[web.1]: rv = self.dispatch_request()
  2020-12-16T12:04:52.431439+00:00 app[web.1]: File &quot;/app/.heroku/python/lib/python3.6/site-packages/flask/app.py&quot;, line 1936, in dispatch_request
  2020-12-16T12:04:52.431439+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args)
  2020-12-16T12:04:52.431440+00:00 app[web.1]: File &quot;/app/app.py&quot;, line 17, in serve
  2020-12-16T12:04:52.431440+00:00 app[web.1]: return app.send_static_file('index.html')
  2020-12-16T12:04:52.431441+00:00 app[web.1]: File &quot;/app/.heroku/python/lib/python3.6/site-packages/flask/helpers.py&quot;, line 1084, in send_static_file
  2020-12-16T12:04:52.431441+00:00 app[web.1]: self.static_folder, filename, cache_timeout=cache_timeout
  2020-12-16T12:04:52.431441+00:00 app[web.1]: File &quot;/app/.heroku/python/lib/python3.6/site-packages/flask/helpers.py&quot;, line 767, in send_from_directory
  2020-12-16T12:04:52.431442+00:00 app[web.1]: raise NotFound()
  2020-12-16T12:04:52.431442+00:00 app[web.1]: werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try
  again.
  </code></pre>
  <p>Directory structure:</p>
  <pre><code>ROOT
  ├── app.py
  ├── build
  ├── dbfiller.py
  ├── logs
  ├── media
  ├── node_modules
  ├── openacademia.db
  ├── package.json
  ├── package-lock.json
  ├── Procfile
  ├── public
  ├── __pycache__
  ├── README.md
  ├── requirements.txt
  ├── src
  ├── venv
  └── yarn.lock
  </code></pre>
  <p>Procfile:
  <code>web: gunicorn --bind 0.0.0.0:$PORT app:app</code></p>
  <p>Let me know if anything else is needed</p>