0

I'm trying to deploy my Python app on Heroku, and have a simple html page that uses it (for now a simple Hello World will do). I think I have successfully deployed the Python app, and it's functioning properly, because when I send a POST request to the url, I get the correct output:

import requests

resp = requests.post('https://name-classification.herokuapp.com/predict', data={'name': 'Marshall'})

print(resp.text)

Output:

{"name":"Marshall","predictoin":"English"}

Process finished with exit code 0

But it seems that the html / PHP part is not working, since I'm seeing a 404 not found error when I visit the webpage:

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

From what I read I understand that I need to have an index.php file in the root directory, which refers to the html file, also in the main directory. So this is my project structure:

+root
  +app
    -__init__.py
    -main.py
    -torch_utils.py
  -.gitignore
  -composer.json
  -home.html
  -index.php
  -Procfile
  -wsgi.py

home.html:

Hello World!
    

index.php:

<?php include_once("home.html"); ?>

composer.json:

{}

And following Heroku's tutorial for setting multiple buildpacks for multi languages in the same project, I did the following

heroku buildpacks:set heroku/python
heroku buildpacks:add --index 1 heroku/php

And it seems that the buildpacks were set successfully:

heroku buildpacks
=== name-classification Buildpack URLs
1. heroku/php
2. heroku/python

But after committing and pushing my changes, I still see the 404 not found error.

Do I need to do anything more to make it work?

Alaa M.
  • 4,961
  • 10
  • 54
  • 95
  • 2
    Only one buildpack is actually used at runtime. If you have two different apps, use two different dynos. – jonrsharpe Aug 06 '21 at 17:58
  • @jonrsharpe - thanks, that worked (I had to enable cross domain though to avoid CORS error, which I did by following these answers: [\[1\]](https://stackoverflow.com/a/53997253/900394) or [\[2\]](https://stackoverflow.com/a/46637194/900394)) – Alaa M. Aug 10 '21 at 13:07

0 Answers0