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.2.tar.gz (676.5 kB view details)

Uploaded Source

Built Distribution

django_simple_api-0.2.2-py3-none-any.whl (684.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-simple-api-0.2.2.tar.gz
  • Upload date:
  • Size: 676.5 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.2.tar.gz
Algorithm Hash digest
SHA256 bb8fac7019bd80ea4af6f5fcb99e07cb233bd9678ae0ad92e422f7b465dc3b6c
MD5 f0e7adf671917286dc164bbb9ef5b822
BLAKE2b-256 4e51e1d9667b1c76f5f1108d6e087278e293762ccd04c6ac9f26d17b751bc8a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_simple_api-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1d93f0e8f69dcfbaf72902569da3fd1db63f2080bc843e8fcca3a3551cdaf34
MD5 26701dba527dc83db33f66a877cb8293
BLAKE2b-256 be885a0cb4be7c2c603715ad7a280d32138a4833a1b068748f95ea9740c29582

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