Skip to main content

A non-intrusive component that can help you quickly create APIs.

Project description

Language: English | Chinese

Django Simple API

A non-intrusive component that can help you quickly create APIs.

Quick Start

Install

Download and install from github:

pip install django-simple-api

Configure

Add django-simple-api to your INSTALLED_APPS in settings:

INSTALLED_APPS = [
    ...,
    "django_simple_api",
]

Register the middleware to your MIDDLEWARE in settings:

MIDDLEWARE = [
    ...,
    "django_simple_api.middleware.SimpleApiMiddleware",
]

Add the url of django-simple-api to your urls.py:

# urls.py

from django.urls import include, path
from django.conf import settings

# Your urls
urlpatterns = [
    ...
]

# Simple API urls, should only run in a test environment.
if settings.DEBUG:
    urlpatterns += [
        # generate documentation
        path("docs/", include("django_simple_api.urls"))
    ]

Complete the first example

Define your url:

# your urls.py

from django.urls import path
from yourviews import JustTest

urlpatterns = [
    ...,
    path("/path/<int:id>/", JustTest.as_view()),
]

Define your view:

# your views.py

from django.views import View
from django.http.response import HttpResponse

from django_simple_api import Query


class JustTest(View):
    def get(self, request, id: int = Query()):
        return HttpResponse(id)

⚠️ To generate the document, you must declare the parameters according to the rules of Simple API (like the example above).

Click Declare parameters to see how to declare parameters.

Access interface document

After the above configuration, you can start your server and access the interface documentation now.

If your service is running locally, you can visit http://127.0.0.1:8000/docs/ to view your documentation.

More

For more tutorials, see Django Simple API.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-simple-api-0.2.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

django_simple_api-0.2.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file django-simple-api-0.2.1.tar.gz.

File metadata

  • Download URL: django-simple-api-0.2.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.3

File hashes

Hashes for django-simple-api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 def29d885f03641c011dfda2fe424b83e69e6095d9fe911edc95a1d56046c1af
MD5 87fb09379d5cc205dc111bfe7f63009d
BLAKE2b-256 e50daebf31e5b4aeb1521bbc15d7369247282f67416239f96e8fc3b05c0e1c61

See more details on using hashes here.

File details

Details for the file django_simple_api-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_simple_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 70d85a5b49a1a1aa230926effc534c69fe4c37146b4808c9eda68e7f1c3767a7
MD5 2d6044df331d5540ffcb48ec2c2c31fe
BLAKE2b-256 ae2c14b214872d2788c4da57229fb1bbda442d33ee7b69f6adc3142c1e1baf97

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page