Django for a simple web application

I am developing an application (API) in python, and I would like to offer some of its functions through a web interface (e.g. web services). I looked at the django, but I don’t know if this fits my idea well. I just want to create a webpage that calls my API methods to implement functions that offer this webpage. But after the tutorial, I'm a little confused about the django point. It seems to me that I'm more connected with ORM than with a classic web application.

Is django so difficult for such a simple development (as I mentioned, making calls in my API over the Internet)? Do I always need to use a database?

Thank.

+3
source share
5

django, , ! , urls.py views.py, URL- , , HTTP.

. urls.py

urlpatterns += patterns('myapp.views',

    url(r'^getstuff/$', 'getstuff' ),
)

views.py

def getstuff(request):

   do whatever in python

   return HttpResponse(stuff to return)
+5

Django. django , MVC ( MVT, ). , , URL-, ..

, :

  • URL- urls.py django
  • django, - api

, familiar , URL-, . , , django.

- , -. , - .

+4

: , - , Apache, "-" ( ) ?

Apache, - Werkzeug, WSGI . Jinja2.

, , , , (-, , - HTML XML, , URL-), SimpleHTTPServer CGIHTTPServer , Python.

Django - , , - . , ( , ), , , .

+1

. wsgi , . WebOb

Raw wsgi

def application(environ, start_response):
    start_response("200 OK", [])
    return ["<html><body><h1>Hello World</h1></body></html>"]

webob

from webob.dec import wsgify
from webob import Request

@wsgify
def application(request):
    return Response("<html><body><h1>Hello World</h1></body></html>")

, apache mod_wsgi, , , / Webob. , Turbogears 2 repoze.bfg .

+1

Django. , . - Python, .

0

Source: https://habr.com/ru/post/1751879/


All Articles