![](/img/trans.png)
[英]How to upload photos to a file in my computer using Django rest framework
[英]How to make a django rest api run a python file in my computer
我正在為 android 應用程序制作 API。 一旦將輸入提供給 API,我就需要 API 來為我執行我計算機中的 python 文件。 我正在考慮將我的計算機用作試用服務器。 我希望你能理解我的問題。 請讓我知道如何從 API 運行 python 文件
您可以看到,當有人訪問該 url 時,它將啟動另一個進程:
from django.http import HttpResponse
from django.views.generic import View
import subprocess
class ExecutePythonFileView(View):
def get(self, request):
# Execute script
subprocess.call(['python', 'somescript.py'])
# Return response
return HttpResponse("Executed!")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.