1. 程式人生 > 其它 >django專案部署

django專案部署

進入虛擬環境:
pip install django==3.2.5 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install uwsgi -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

pip install djangorestframework -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install djangorestframework-jwt -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install pymysql  -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

pip install django-cors-headers -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

cd /djpro1/p1/mydrf
django-admin startproject mydfr
cd /django/p1/mydfr
python manage.py startapp app01

Python uWSGI 安裝配置
https://www.runoob.com/python3/python-uwsgi.html
https://www.cnblogs.com/jinggege-0224/p/12607484.html
https://www.cnblogs.com/jinggege-0224/p/12607484.html

https://blog.csdn.net/cz9025/article/details/86681428
測試uwsgi,報錯Unhandled object from iterator

wuyepiaoxue789 2021-01-05 16:06:30 301 收藏 1
分類專欄: Python
版權

Python
專欄收錄該內容
28 篇文章0 訂閱
訂閱專欄
pip install uwsgi
uwsgi --version # 檢視 uwsgi 版本
測試 uwsgi 是否正常:

新建 test.py 檔案,內容如下:

def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return "Hello World"
然後在終端執行:

uwsgi --http :8001 --wsgi-file test.py
在瀏覽器內輸入:http://127.0.0.1:8001,檢視是否有"Hello World"輸出

訪問地址,後臺報錯:

解決:對於python3則應當注意要指明編碼,否則uwsgi不會發送網頁內容

​def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
test = 'hello world'

————————————————
版權宣告:本文為CSDN博主「wuyepiaoxue789」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處連結及本宣告。
原文連結:https://blog.csdn.net/wuyepiaoxue789/article/details/112240544

uWSGI的安裝及配置詳解
https://blog.csdn.net/weixin_42134789/article/details/115713572