Forums

how to set up my homepage

I'm sorry for this stupid question but i always get the same homepage like this (Hello, World! This is the default welcome page for a PythonAnywhere hosted web application. Find out more about how to configure your own web application by visiting the web app setup page. )

even though i have already set up my wsgi , i still dont get my project homepage . what should i do ? can someone please help me on how to change my default homepage. here is the exact syntax i included inside my wsgi

activate_this = '/home/msabelita/.virtualenvs/rango/bin/activate_this.py'

execfile(activate_this, dict(__file__=activate_this))

import os

import sys

path = '/home/<username>/mytangowithdjango/tango_with_django_project'

if path not in sys.path:
    sys.path.append(path)

os.chdir(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'tango_with_django_project.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

[edited by admin: formatting]

Did you hit the "Reload" button?

yes i have already hit the reload button but i still get the same output i tried to search for the solution in the internet but still i cant find a way to solve this problem ??

i also think this one is executed not my actual project , but when every time a delete this one i got an unhandeld error

from flask import Flask
application = Flask(__name__)

@application.route('/')

def hello_world():

    return """

            <html>

            <head>

                <title>Python Anywhere hosted web application</title>

            </head>

            <body>

            <h1>Hello, World!</h1>

            <p>

                This is the default welcome page for a

                <a href="https://www.pythonanywhere.com/">PythonAnywhere</a>

                hosted web application.

            </p>

            <p>

                Find out more about how to configure your own web application

                by visiting the <a href="https://www.pythonanywhere.com/web_app_setup/">web app setup</a> page

            </p>

            </body>

            </html>"""

[edited by admin: formatting]

Where are you putting the WSGI code that you gave in your first post?

inside this WSGI configuration file: (/var/www/msabelita_pythonanywhere_com_wsgi.py )

Can I take a look at your files?

https://github.com/cmsabelita/mytangowithdjango here sir

Sorry, I meant the code inside your PythonAnywhere account. We can look at it from here, but we always ask for permission first, as a matter of privacy.

sure here is my account https://www.pythonanywhere.com/user/msabelita/account/

Thanks!

So, it looks like the problem is that your WSGI file contains two different applications. Firstly, you have the Django settings, which look OK. And then after that, you have the default "Hello, world" app. And the second one is overriding the first.

Your WSGI file should only contain the Django one.

so what should i do ? do i have to comment out all codes inside flask ? sorry for the question i am total beginner (-/\-)

Comment it out or delete it, whichever you prefer :-)

i got this unhandled exception err then i check on my log and i notice that it produce (ImportError: Could not import settings 'settings.py') error

i got this unhandled exception err then i check on my log and i notice that it produce (ImportError: Could not import settings 'settings.py') error

Right, that looks like a bug in your WSGI file. In there, you say:

path = '/home/msabelita/mytangowithdjango/tango_with_django_project'
if path not in sys.path:
    sys.path.append(path)

This tells Python that it should look for files inside the directory /home/msabelita/mytangowithdjango/tango_with_django_project.

Next, you say:

os.chdir(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'tango_with_django_project.settings'

This tells Python that your settings are in a file called settings.py inside a directory tango_with_django_project.

So, combined, that means that it's looking for your settings in the file /home/msabelita/mytangowithdjango/tango_with_django_project/tango_with_django_project/settings.py -- note that tango_with_django_project appears twice.

But your settings file is actually /home/msabelita/mytangowithdjango/tango_with_django_project/settings.py, with just one tango_with_django_project.

So the best solution is probably to remove the tango_with_django_project from the path = ... line.

thanks sir (0/\0) .

No problem! Is it all working now?