Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd6702d2

Browse files
authored
Add files via upload
1 parent9281cb8 commitd6702d2

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

‎convert.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python3
2+
3+
importrequests
4+
importos,json
5+
6+
fromrequests_toolbeltimportMultipartEncoder
7+
8+
url="http://localhost/unoconv/pdf"
9+
10+
defpost_file(url,path):
11+
filename=os.path.basename(path)
12+
convert_name=str(filename).split('.')[0]+'.pdf'
13+
14+
m=MultipartEncoder(
15+
fields= {
16+
'file':(filename,open(path,'rb')),
17+
}
18+
)
19+
response=requests.request('POST',url,data=m,headers={'Content-Type':m.content_type})
20+
21+
withopen(convert_name,'wb')asf:
22+
f.write(response.content)
23+
24+
returnconvert_name
25+
26+
path="./demo.docx"
27+
28+
ret=post_file(url,path)
29+
print(ret)
30+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp