Forums

Deploying fastHTML website

Hi, I've been trying to follow the instructions here to deploy a fastHTML website https://help.pythonanywhere.com/pages/ASGICommandLine/#fasthtml. I got to the end with a success. However, the output from the default WSGI file is showing and not the main.py from fastHTML. Any tips on how to change the WSGI file?

Defauld wsgi file is not used for asgi apps.

Thank you for the response. So what do I do inside of the WSGI configuration file under Web -> Code?

I updated it with this code:

# Add your project directory to the sys.path
path = '/home/enokiwindow/my_fasthtml'
if path not in sys.path:
    sys.path.append(path)

# Set the environment variable for Django settings
os.environ['PYTHONANYWHERE_SITE'] = "enokiwindow.pythonanywhere.com"

# Import the FastHTML app from your main.py
from main import app as application  # This points to the app defined in main.py

but still got an error

If you already have a normal website at YOURUSERNAME.pythonanywhere.com, then you won't be able to deploy a FastHTML site -- unfortunately, the pa helper script documented on the page you linked to earlier doesn't handle that error case correctly, so it looks like it was successful.

You should delete the existing non-FastHTML site from the "Web" page, and then run through those instructions again -- then it will actually create the site.

Thank you for your help!

Let us know if you need any extra help.