In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Display the contents of the linux server on the web page
Django Project name: minicms
/ home/username/minicms
App name in the project: news
/ home/username/minicms/news
Related files: / tmp/abc.txt
# cat / tmp/abc.txt Public Network IP address: 183.54.15.11 Server memory: 192.168.1.1total used free shared buffers cachedMem: 742691 500388 + buffers/cache: 571170Swap: 991817 174192.168.1.2total used free shared buffers cachedMem: 742 691 500 31 88 buffers/cache + 571 170Swap: 991817 174
Views.py file: / home/username/minicms/news/views.py
# coding:utf-8from django.http import HttpResponsefrom django.shortcuts import renderimport osimport subprocess# def shell (request): # os.system ("/ bin/bash / tmp/abc.sh") def index (request): # execute the server system command os.system ("/ bin/bash / tmp/abc.sh") # Open the file fo = open ('/ tmp/abc.txt','r') # Save variable List=fo.xreadlines () # return the list list Pass to home.html template return render (request,'home.html', {'aList':List}) # return render (request,'home.html')
Urls.py file: / home/username/minicms/minicms/urls.py
# spicy Chicken 51, this code is sent out and does not show, I'd better take a screenshot.
Home.html template file: / home/username/minicms/news/templates/home.html
Test page {% for item in aList%}
{{item}}
{% endfor%}
The page is displayed:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.