FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
flypython/convert.py at master · flypythoncom/flypython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
flypythoncom
/
flypython
Public
Notifications
You must be signed in to change notification settings
Fork
3
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
flypython
/
convert.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (20 loc) · 626 Bytes
Breadcrumbs
flypython
/
convert.py
Copy path
File metadata and controls
30 lines (20 loc) · 626 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
import
requests
import
os
,
json
from
requests_toolbelt
import
MultipartEncoder
url
=
"http://localhost/unoconv/pdf"
def
post_file
(
url
,
path
):
filename
=
os
.
path
.
basename
(
path
)
convert_name
=
str
(
filename
).
split
(
'.'
)[
0
]
+
'.pdf'
m
=
MultipartEncoder
(
fields
=
{
'file'
:(
filename
,
open
(
path
,
'rb'
)),
}
)
response
=
requests
.
request
(
'POST'
,
url
,
data
=
m
,
headers
=
{
'Content-Type'
:
m
.
content_type
})
with
open
(
convert_name
,
'wb'
)
as
f
:
f
.
write
(
response
.
content
)
return
convert_name
path
=
"./demo.docx"
ret
=
post_file
(
url
,
path
)
print
(
ret
)
Back
|
FazBrowse Home
|
New Git URL