Re:Why SQLite Is Taking over with Brian Holt and Marco Bambini
by fud101 on Wednesday June 12, 2024 @07:20AM
(#40656784)
Django in one file? How?
[ Parent
| on HN ]
Re:Why SQLite Is Taking over with Brian Holt and Marco Bambini
by mg on Wednesday June 12, 2024 @07:47AM
(#40656965)
You just need a wsgi.py file:
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),
]
Put that file in /var/www/mysite/mysite/wsgi.py, point your webserver to that file and you are good to go. In Apache you do it like this: ServerName mysite.local
WSGIPythonPath /var/www/mysite
<VirtualHost *:80>
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
<Directory /var/www/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
Re:Why SQLite Is Taking over with Brian Holt and Marco Bambini
by pjc50 on Wednesday June 12, 2024 @07:56AM
(#40657049)
> import django
Not really in one file, is it?
Re:Why SQLite Is Taking over with Brian Holt and Marco Bambini
by TeMPOraL on Wednesday June 12, 2024 @08:20AM
(#40657251)
If you somehow managed to shove Python and Django into https://redbean.dev/2.0.html, then it might just work as bona fide one file.
Re:Why SQLite Is Taking over with Brian Holt and Marco Bambini
by mg on Wednesday June 12, 2024 @08:24AM
(#40657276)
One file in your project.
'apt install sqlite3' will install more than one file too. But the DB that is in your project is just one file.
Re:Why SQLite Is Taking over with Brian Holt and Marco Bambini
by adparadox on Wednesday June 12, 2024 @07:25AM
(#40656810)
https://coltrane.readthedocs.io/en/latest/#other-minimal-dja... has a list of a few options, but the most recent is https://github.com/pauloxnet/uDjango.