What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
1–10 of 63 posts
Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
#2Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
#3Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
#4Django getting background tasks built-in is going to be really nice. It sucked having to manage celery or similar alongside it.
Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
#5Django getting background tasks built-in is going to be really nice. It sucked having to manage celery or similar alongside it.
You should check out Huey next time. It is a lifesaver for us. Allows us to do the tasks via SQLite db
Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
#6I wish they could make it easy to deploy django or other python framework in a serverless function with decent security baked in.
Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
#7Edit: Ooops. IPython magics don't seem to work. I hope they add it.
Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
#8You can turn a fresh Debian machine into a running Django web app by just doing:
apt install -y python3-django apache2 libapache2-mod-wsgi-py3
And then creating the one file Django needs:/var/www/mysite/mysite/wsgi.py:
import os
import django
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.wsgi')
application = get_wsgi_application()
ROOT_URLCONF = 'mysite.wsgi'
SECRET_KEY = 'hello'
def index(request):
return django.http.HttpResponse('This is the homepage')
def cats(request):
return django.http.HttpResponse('This is the cats page')
urlpatterns = [
django.urls.path('', index),
django.urls.path('cats', cats),
]
And then telling Apache where to look for it:/etc/apache2/sites-enabled/000-default.conf:
ServerName 127.0.0.1
WSGIPythonPath /var/www/mysite
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
Require all granted
And voilá, you have a running Django application, which you can expand upon to any size and complexity.If you want to try it in a docker container, you can run
docker run -it --rm -p80:80 debian:12
perform the steps above and then access the Django application at 127.0.0.1Re: What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
#9What I love about Django is that you can create a Django project with just one file. You can turn a fresh Debian machine into a running Django web app by just doing: apt install -y python3-django apache2 libapache2-mod-wsgi-py3 And then creating the one file Django needs: /var/www/mysite/mysite/wsgi.py: import os import django from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MO…
WSGI is old tech that in your example requires extra packages and code in project to work. By now Python should stand on its own and handle this independently, being proxied to by better http servers like nginx or caddy.