xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Python Web Framework All In One

Django and Flask are the top Python web frameworks so far.

Django

https://github.com/django/django

Flask

https://github.com/pallets/flask/

django vs flask

demo

https://docs.djangoproject.com/en/3.1/intro/tutorial01/

django

$ python -m django --version

$ django-admin startproject mysite

# dev
$ python manage.py runserver



from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

from django.urls import path

from . import views

urlpatterns = [
    path('', views.index, name='index'),
]

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('polls/', include('polls.urls')),
    path('admin/', admin.site.urls),
]



flask

from flask import Flask, escape, request

app = Flask(__name__)

@app.route('/')
def hello():
    name = request.args.get("name", "World")
    return f'Hello, {escape(name)}!'
$ env FLASK_APP=hello.py flask run
 * Serving Flask app "hello"
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

MDN

https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django

https://developer.mozilla.org/en-US/docs/Learn/Server-side/First_steps

https://developer.mozilla.org/en-US/docs/Glossary/Python

refs

https://ncube.com/blog/top-python-web-frameworks-2020

https://steelkiwi.com/blog/top-10-python-web-frameworks-to-learn/

https://wiki.python.org/moin/WebFrameworks



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


原文地址:https://www.cnblogs.com/xgqfrms/p/14257154.html