3 ms·
Django in one file? How?
by fud101 2y ago
Django in one file? How?
- adparadox 2y agohttps://coltrane.readthedocs.io/en/latest/#other-minimal-django-projects 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 https://github.com/pauloxnet/uDjango.
- mg 2y agoYou 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>
- pjc50 2y ago> import django Not really in one file, is it?
- TeMPOraL 2y agoIf you somehow managed to shove Python and Django into https://redbean.dev/2.0.html https://redbean.dev/2.0.html, then it might just work as bona fide one file.
- mg 2y agoOne 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.