Web development based on hi-nginx (python) -- start, hi-nginxpython
Hi-nginx not only makes python web applications run fast, but also makes related development simple and agile.
For the installation of hi-nginx, see: https://www.cnblogs.com/hi-nginx/p/8622561.html
It is often said thatFlaskThe framework is fast and good. However, it is still too slow to compare hi-nginx. For exampleFlaskThe minimum application of is as follows:
1 from flask import Flask2 app = Flask(__name__)3 4 @app.route('/')5 def hello_world():6 return 'Hello World!'7 8 if __name__ == '__main__':9 app.run()
However, the minimum python application of hi-nginx is simpler:
1 if hi_req.uri()=='/test.py':2 hi_res.content('hello,world')3 hi_res.status(200)
Of course, you can also make the minimum application write more complex, such:
1 def hello_world(): 2 hi_res.content('hello,world') 3 hi_res.status(200) 4 5 def run(): 6 if hi_req.uri()=='/': 7 hello_world() 8 9 if __name__ == '__main__':10 run()
How can I access the application after it is written? It's easy to write in the hi-nginx configuration file as follows:
server { listen 8080; server_name localhost; location / { hi_need_cache off; hi_python_script python/index.py; }}
Reload or restart nginx, and then visit http: // localhost: 8080/To see hello, world greetings.
Now we use siege to test the performance of this minimum application:
Siege-c 1000-r 100-B http: // 127.0.0.1: 8080/
Are you satisfied!