Hello everyone, today the editor has paid attention to a more interesting topic, which is the question about website development tutorials, so the editor has compiled a related answer to introduce website development tutorials, Let's take a look. (web development) Create the simplest website with python? (web development) Create the simplest website with python? 1. Before starting, please visit the following web page with a browser: http://127.0.0.1:900/2. First define a function to send a request to the web server: def yingyong(environ, start_response):start_response( '200 OK', [('Content-Type', 'text/html')])return [b'
How Are!
'] requires the website to display bold How Are!3 on the page , Import the submodule of the wsgi module to create the server. from wsgiref.simple_server import make_server4. Create a server with an empty IP and a port number of 900. a=900httpd = make_server('', a, yingyong) This server will call the previous function yingyong. 5. Let the server start running and run for a long time. httpd.serve_forever() forever, let the server run forever, unless the server is forced to shut down. where is the server? Just in python, closing the python compiler is equivalent to closing the server. 6. Visit the link in step 1 again, and you will get the following web page, which means that the server is running. 7. Refreshing this webpage is equivalent to repeatedly visiting this webpage. Every time you visit (refresh), a request will be sent to the server, which will be reflected in the python compiler. 8. Close the python compiler, the server will be closed, and the webpage will crash immediately. Open python again and run this code, and the web page will be restored immediately. The complete code is as follows: def yingyong(environ, start_response):start_response('200 OK', [('Content-Type', 'text/html')]) return [b'
How Are!
' ]from wsgiref.simple_server import make_servera=900httpd = make_server('', a, yingyong)httpd.serve_forever() In this article, use python to create the simplest web page. 1 First define a function to send a request to the web server: def yingyong(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) return [b'< h1>How Are!'] requires the website to display the bold How Are! 2 import submodule of the wsgi module to create the server. from wsgiref.simple_server import make_server. 3Create a server, the IP is empty, and the port number is 900. a=900httpd = make_server('', a, yingyong) This server will call the previous function yingyong. 4 Get the server up and running for a long time. httpd.serve_forever() forever, let the server run forever, unless the server is forced to shut down. where is the server? Just in python, closing the python compiler is equivalent to closing the server. 5 Visit the link in step 1 again, and you will get the following web page. This means the server is up and running. Refreshing this web page is equivalent to repeatedly visiting this web page. Every time you visit (refresh), a request will be sent to the server, which will be reflected in the python compiler. 6 Close the python compiler, the server will be closed, and the webpage will crash immediately. Open python again and run this code, and the web page will be restored immediately. The complete code is as follows: def yingyong(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) return [b'
How Are!
' ] from wsgiref.simple_server import make_servera=900httpd = make_server('', a, yingyong)httpd.serve_forever(). So far, the above is the introduction of the editor's questions about the website development tutorial. I hope that the one-point answer about the website development tutorial will be useful to everyone.
