Giter VIP home page Giter VIP logo

udjango's Introduction

🧬 μDjango (micro Django)

A single file Django micro project created for demonstration purposes to be used in the same way as other Python frameworks.

🏛️ History

I created this code while working on an improvement to Will Vincent's Django Microframework repository, which was itself inspired by Carlton Gibson's talk.

Starting from that demonstration code I thought of a Django micro application that could be used in the same way as a minimal application used in other Python frameworks such as Flask or FastAPI.

I presented this code during the first sprint day of DjangoCon US 2023, together with Will Vincent and seeing the appreciation I decided to publish it in this repository.

μDjango presentation during the DjangoCon US 2023 sprints in Durham, North Carolina

μDjango presentation during the DjangoCon US 2023 sprints in Durham, North Carolina

💻 Set Up

⚗️ Virtualenv

Creating and activating the virtual environment:

$ python3 -m venv .venv
$ source .venv/bin/activate

🧩 Requirements

Installing the required python packages in the virtual environments:

(.venv) $ python3 -m pip install django uvicorn[standard]

🧮 Code

Create a new file called udjango.py and update it as follows:

from django.conf import settings
from django.core.handlers import asgi
from django.http import JsonResponse
from django.urls import path

settings.configure(ALLOWED_HOSTS="*", ROOT_URLCONF=__name__)

app = asgi.ASGIHandler()


async def root(request):
    return JsonResponse({"message": "Hello World"})


urlpatterns = (path("", root),)

🏃 Run

Start the server with uvicorn command.

(.venv) $ uvicorn udjango:app --reload

🔬 Check it

Open your browser at http://127.0.0.1:8000

You will see the JSON response as:

{"message": "Hello World"}

⚠️ Disclaimer

This code is for demonstration purposes only and should not be used in production. However, the code is released without any guarantee from the author and no liability can be attributed. Use at your own risk.

⚖️ License

μDjango is licensed under the BSD 3-Clause License.

👥 Authors

👤 Paolo Melchiorre

udjango's People

Contributors

pauloxnet avatar mogul avatar joshuadavidthomas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.