How to put a website online

While the server runs on your computer, only you can see the site. Let us see how to publish the to-do list from the first project for free on PythonAnywhere, a hosting service made for Python that needs no server setup.

A drawing by Samuel Loxton, 1908: the first printing press of the Daily Press newspaper, Bristol, 1858

What you get and the limitations

After publishing, the app opens at https://your-username.pythonanywhere.com.

The free Beginner plan

  • One web app at username.pythonanywhere.com
  • 512 MB of disk: plenty for a learning project with SQLite
  • The app runs for a month; then you extend it with a button on the Web tab
  • Internet access from your code only to sites on an allowlist
  • 100 CPU seconds a day for code in consoles; the site itself does not use them

The order of steps

  1. Put the code on GitHub
  2. Copy it to PythonAnywhere and install the dependencies
  3. Create a web app and point it to the WSGI file
  4. For Django: set up the address and static files
  5. Press Reload and open the site

The plan terms come from the PythonAnywhere help as of November 2026 and may change; current details are in the sources at the bottom of the page.

Step-by-step guide

In the commands, replace username with your PythonAnywhere username and USER/REPO with the address of your GitHub repository.

  1. Step 1. Prepare the project and put it on GitHub

    The requirements.txt file lists the project's libraries, and the server installs the same ones from it. The .gitignore file keeps the environment and the local database out of the repository. Create the repository on github.com first.

    Terminal (in the project folder)
    pip freeze > requirements.txt
    git init
    git add .
    git commit -m "First project: task list"
    git branch -M main
    git remote add origin https://github.com/USER/REPO.git
    git push -u origin main
    .gitignore
    .venv/
    __pycache__/
    *.db
    db.sqlite3
    static/
  2. Step 2. Copy the code to PythonAnywhere

    Sign up at pythonanywhere.com (Beginner plan), open the Consoles tab and start Bash. The mkvirtualenv command creates an environment and activates it right away.

    Terminal (Bash console on PythonAnywhere)
    git clone https://github.com/USER/REPO.git mysite
    mkvirtualenv --python=/usr/bin/python3.13 mysite-venv
    cd mysite
    pip install -r requirements.txt

    Python 3.13 is available only in the innit system image. If the command says python3.13 is not found, open the Account page, the System image tab, and choose innit.

  3. Step 3. Create a web app

    On the Web tab, press Add a new web app, choose Manual configuration (not the ready Flask or Django template, which creates an empty project) and the same Python 3.13. Then type mysite-venv in the Virtualenv section: the path completes itself.

  4. Step 4. Set up the WSGI file

    The WSGI file tells the server where your app is. Open the link to it in the Code section of the Web tab, delete everything and paste the version for your framework.

    WSGI file: Flask
    import sys
    
    path = "/home/username/mysite"
    if path not in sys.path:
        sys.path.insert(0, path)
    
    from app import app as application
    WSGI file: Django
    import os
    import sys
    
    path = "/home/username/mysite"
    if path not in sys.path:
        sys.path.insert(0, path)
    
    os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"
    
    from django.core.wsgi import get_wsgi_application
    application = get_wsgi_application()

    The line from app import app means “take the app object from the file app.py”. If your file has a different name, change the first word.

  5. Step 5. Django only: address, database and static files

    In mysite/settings.py, turn off debug mode, allow your address and set a folder for static files: without it the admin opens without styling. Then run the commands in the Bash console.

    mysite/settings.py
    DEBUG = False
    
    ALLOWED_HOSTS = ["username.pythonanywhere.com"]
    
    STATIC_ROOT = BASE_DIR / "static"
    Terminal (Bash console on PythonAnywhere)
    cd ~/mysite
    workon mysite-venv
    python manage.py migrate
    python manage.py collectstatic
    python manage.py createsuperuser

    On the Web tab, in the Static files section, add a line: URL /static/, Directory /home/username/mysite/static.

  6. Step 6. Reload and check

    Press the green Reload button on the Web tab and open https://username.pythonanywhere.com. If you see an error instead of the site, open the Error log on the same tab: the last line usually tells you why.

How to update the site and what not to do

Terminal: updating after code changes
cd ~/mysite
git pull
# for Django, if the models changed:
python manage.py migrate
# then the Reload button on the Web tab

Security

  • Do not leave DEBUG = True on the server: on an error, visitors would see your settings and pieces of code.
  • The SECRET_KEY from settings.py must not be in a public repository: keep it in an environment variable.
  • Do not push a database with real data to GitHub: that is why .gitignore contains *.db.

No project to publish yet?

Build a to-do list with Flask or Django: it takes from half an hour.