In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge about "how to install python script framework webpy". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
One: install pip install web.py Two: URL processing
The most important part of any website is its URL structure.
urls=('/',' Index',) #defines a mapping rule that sends requests for the virtual path '/' to the Index class for processing.
III: Category
Defines an Index class to handle requests for '/', which can be handled according to their own requirements, which may be GET,POST...
class Index: def GET(self): return 'Hello, everyone' 4: Create an app=web.application (urls,globals()) #Create app object app.run() #Launch app 5: instance import web#basic elements of the web #1.urls routing table #2. a web.application instance app#3. startup appurls are url mapping rules, similar to (servert) mapping urls=('/',' Index')#This sentence means that the request sent to the virtual path ' / ' is handed over to the Index class to handle #This url variable designs a URL control scheme for the entire website #Define an Index class to handle routing class Index: def GET(self): #Prevent Chinese garbled characters web.header('Content-Type','text/html;charset=UTF-8') #Your operation can return str, file,html # return "get request! " # return open(r'F:\GitHub\Python\MyWeb\tesseract.log') return 'GET request' def POST(self): return 'post request! '#Create an app=web.application(urls,globals())#The urls parameter indicates a mapping between the url of the website and the functions executed by the application, but you can see that urls is a tuple, and only the string #globals() in the tuple will return a dictionary-like object containing all variables, functions, classes, and modules in the current space. The key is the name of these things, and the value is the response object, so that you can get the object by name. if __name__ == '__main__': app.run ()"Python script framework webpy how to install" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
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.