Cara menggunakan pythonanywhere documentation

I have a free account at pythonanywhere.com. My thanks to them for providing this very nice free service and learning experience.

To the PythonAnywhere folks who encourage me to use StackOverflow for questions about their site, I'll first say that I really like what you all have done with that site, and I'm excited to start building something there myself.

I've already done the first tutorial within pythonanywhere.com with Flask and a second simple webapp (that I adapted from your first tutorial) exactly the same but using your built-in django 2.2 in place of Flask.

Now I'm trying a tutorial from another site using python 3.8 and django 3.1.

I'm following along in Chapter 2 of the djangoforbeginners.com site (helloworld app) and trying to implement instructions there in my pythonanywhere.com account. I know I need to adapt some of the djangoforbeginners.com instructions to fit the pythonanywhere.com environment (e.g. pipenv didn't work, but pip install django~=3.1.0 did work).

(This is not my main question, but an example of the problems I expect to encounter adapting a tutorial from another site to the pythonanywhere.com environment) I encountered a problem with the python manage.py runserver step:

When I run the code above, I see the following error at the bash console:

Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
August 13, 2020 - 20:33:32
Django version 3.1, using settings 'config.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Error: That port is already in use.

And that makes sense to me because when I try to visit my webapp at username.pythonanywhere.com, I see a "Coming soon" page (after disabling my webapp in the dashboard; with my webapp enabled in the dashboard Web tab, I see a default "Hello World" page) which I know in both cases means that port is indeed already in use (by the server provided by pythonanywhere.com). So thinking about it a bit after seeing that error, I now think I should not even have attempted this python manage.py runserver step in the pythonanywhere.com environment. Duh! ;)

So moving on to my real question:

I've already followed instructions I found at https://help.pythonanywhere.com/pages/Virtualenvs including the part at the end where it reads: "Now that you have a virtualenv, and you know its path, you can go and enter it back in the Web tab.

Go to the Virtualenv section, and enter the path: /home/myusername/.virtualenvs/myvirtualenv"

I created my virtual environment using mkvirtualenv virtualenv01py38 --python=/usr/bin/python3.8 in pythonanywhere.com's bash console.

I also added to the Web tab in pythonanywhere.com's dashboard my source code directory for this web app: /home/username/projects/djangoforbeginners.com/ch02helloworld

When I used the dashboard Web tab to reload the web app, I saw this error message: "Your webapp took a long time to reload. It probably reloaded, but we were unable to check it."

But instead of the familiar Django welcome page, when I visit my webapp's URL, I see an apparently static html page: "Hello, World! This is the default welcome page for a PythonAnywhere hosted web application..."

So my question in general is how to implement the helloworld app from djangoforbeginners.com within the pythonanywhere.com environment?

And more specifically for now, my question is why I'm not seeing the familiar Django welcome page shown at djangoforbeginners.com in the first image, and how to continue to move forward past the python manage.py runserver step when I am apparently seeing pythonanywhere.com serve up its default hello world webapp (apparently just a static html page) instead of the django 3.1 hello world app that I'm trying to get it to serve up from the djangoforbeginners.com tutorial?

Deploy di PYAW paling mudah karena tidak membutuhkan kita untuk menginstall aplikasi tertentu di komputer, tidak seperti Heroku yang membutuhkan aplikasi Heroku dan Git.

Catatan:

  1. Kalau aplikasinya tidak perlu memakai package dengan versi tertentu, saran saya tidak perlu membuat virtualenv karena memori yang disediakan sangat terbatas (500 MB). Ketika menggunakan virtualenv memori akan termakan banyak untuk install package.

  2. File yang dibutuhkan untuk project kita tinggal di-upload ke PYAW. Jika project terdiri dari beberapa folder dan file (seperti project pada umumnya), akan lebih mudah jika satu kesatuan folder project kita (atau folder tertentu, misal hanya folder static) di-zip terlebih dahulu lalu di-upload di lokasi yang diinginkan.

  3. Contoh: untuk project nyc311 yang membutuhkan file static dalam folder static, upload folder static yang sudah di-zip ke direktori /home/azukacchi/nyc311. File zip dapat di-unzip dengan cara: (1) membuka folder tempat file zip berada lalu "Open Bash console here", atau (2) buka bash console dimana pun lalu ubah direktori ke tempat file zip berada cd /home/azukacchi/nyc311. Setelah bash console terbuka, ketik unzip namafile.zip (dalam kasus ini namafile adalah

      gunicorn
      flask==1.1.2
      imblearn
      plotly==4.14.3
      pandas==1.2.2
      numpy==1.19.2
      sklearn
    
    0). File zip yang terekstrak akan menjadi folder berisi file-file.

    Cara menggunakan pythonanywhere documentation

  4. Jangan lupa isi detail aplikasi di halaman Web.

    Cara menggunakan pythonanywhere documentation

    Cara menggunakan pythonanywhere documentation

Heroku

diadaptasi dari tutorial resmi:

Asumsi:

  • Heroku dan Git sudah ter-install (jika belum, lihat link tutorial)
  • folder project sudah tersedia dengan (dengan atau tanpa menggunakan virtual environment), aplikasi Flask sudah berjalan OK di komputer dan siap di-deploy

Langkah-langkah:

  1. Di dalam folder project, buat beberapa file dengan menggunakan Notepad bernama

      gunicorn
      flask==1.1.2
      imblearn
      plotly==4.14.3
      pandas==1.2.2
      numpy==1.19.2
      sklearn
    
    1,
      gunicorn
      flask==1.1.2
      imblearn
      plotly==4.14.3
      pandas==1.2.2
      numpy==1.19.2
      sklearn
    
    2,
      gunicorn
      flask==1.1.2
      imblearn
      plotly==4.14.3
      pandas==1.2.2
      numpy==1.19.2
      sklearn
    
    3,
      gunicorn
      flask==1.1.2
      imblearn
      plotly==4.14.3
      pandas==1.2.2
      numpy==1.19.2
      sklearn
    
    4 dengan rincian isi file sebagai berikut: