安装WEB库

  • flask安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
pip3 install flask 
#flask需要使用ssl,所以在编译python时,需要打开ssl模块。

#验证
vi test.py3

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
return "Hi 13!"

if __name__ == "__main__":
app.run()

python3 test.py3
* Serving Flask app "test" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Tornado安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
pip3 install tornado

#验证
vi test2.py3

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hi 13")

def make_app():
return tornado.web.Application([
(r"/", MainHandler),
])

if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()

python3 test.py3
#通过浏览器访问8888端口