Skip to content

Commit f031490

Browse files
committed
learning at 20191204
1 parent 559803c commit f031490

3 files changed

Lines changed: 164 additions & 0 deletions

File tree

pipenv.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
# 1 安装pipenv
3+
4+
```bash
5+
pip3 install pipenv
6+
```
7+
8+
# 2 创建虚拟环境
9+
10+
```bash
11+
# mkdir project
12+
# cd project
13+
# pipenv install // 初始化
14+
```
15+
16+
# 3 安装依赖包
17+
18+
```bash
19+
# pipenv install requests
20+
```
21+
22+
# 4 查看安装包及依赖关系
23+
24+
```bash
25+
# pipenv graph
26+
```
27+
28+
只在开发环境中安装
29+
30+
```bash
31+
# pipenv install --dev requests --three
32+
```
33+
34+
```
35+
--three / --two Use Python 3/2 when creating virtualenv
36+
```
37+
38+
# 5 兼容requirements.txt文件
39+
40+
```bash
41+
# pipenv lock -r --dev > requirements.txt
42+
```
43+
44+
```bash
45+
# pipenv install -r requirements.txt
46+
```
47+
48+
# 6 运行Python代码
49+
50+
method 1
51+
52+
```bash
53+
# pipenv run python xxx.py
54+
```
55+
56+
method 2
57+
58+
```bash
59+
# pipenv shell
60+
# python3 xxx.py
61+
```
62+
# 7 删除依赖包
63+
64+
```bash
65+
# pipenv uninstall requests
66+
```
67+
68+
# 8 删除虚拟环境
69+
70+
```bash
71+
# pipenv --rm
72+
```
73+
74+
# 9 设置pip源
75+
76+
编辑Pipfile, 修改url的地址
77+
78+
79+

simple_http_server_py2.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/python
2+
3+
import json
4+
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
5+
6+
PORT_NUMBER = 8000
7+
8+
build_data = {
9+
"id": "env_appname_modulename:12.1",
10+
"envName": "env",
11+
"appName": "appname",
12+
"moduleName": "modulename",
13+
"parentImage": "192.168.1.2:5000/weblogc.12.1",
14+
"context": "xxx",
15+
"mountnfs": [
16+
{
17+
"srcDir": "172.10.1.100:/share",
18+
"destDir": "/share"
19+
}
20+
],
21+
"datasource": [
22+
{
23+
"dsdriver": "abc",
24+
"dsjndiname": "jdbc/dafdasf",
25+
"dsname": "xxx",
26+
"dsurl": "jdbc:oracle:thin:@(dsagasgagasg)",
27+
"dsusername": "hello",
28+
"dspassword": "world",
29+
"globalTransactionProtocol": "OnePhaseCommit"
30+
}
31+
],
32+
"java_options": "-Dfile.encoding=utf-8",
33+
"charset": "UTF-8",
34+
"topic": {
35+
"access": "env-appname-modulename-access",
36+
"server": "env-appname-modulename-server"
37+
}
38+
}
39+
40+
class myHandler(BaseHTTPRequestHandler):
41+
def do_GET(self):
42+
self.send_response(200)
43+
self.send_header("Content-Type", "application/json")
44+
self.end_headers()
45+
self.wfile.write(json.dumps(build_data))
46+
return
47+
48+
49+
try:
50+
server = HTTPServer(("", PORT_NUMBER), myHandler)
51+
print("Started httpserver on port", PORT_NUMBER)
52+
server.serve_forever()
53+
54+
except KeyboardInterrupt:
55+
print("Ctrl C received, shutting down the web server")
56+
server.socket.close()

simple_http_server_py3.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# _*_ coding:utf-8 _*_
2+
#!/usr/bin/python3
3+
4+
import http.server
5+
6+
7+
class RequestHandler(http.server.BaseHTTPRequestHandler):
8+
9+
page = """
10+
<html>
11+
<body>
12+
<p> Hello, Web! </p>
13+
</body>
14+
</html>
15+
"""
16+
17+
# handle request
18+
def do_GET(self):
19+
self.send_response(200)
20+
self.send_header("Content-Type", "text/html")
21+
self.send_header("Content-Length", str(len(self.page)))
22+
self.end_headers()
23+
self.wfile.write(self.page)
24+
25+
26+
if __name__ == "__main__":
27+
serverAddress = ("", 8080)
28+
server = http.server.HTTPServer(serverAddress, RequestHandler)
29+
server.serve_forever()

0 commit comments

Comments
 (0)