Spaces:
Running
Running
Update main.py
#1
by
nhathuy07
- opened
main.py
CHANGED
@@ -37,6 +37,9 @@ from re import sub
|
|
37 |
|
38 |
import redis.asyncio as redis
|
39 |
|
|
|
|
|
|
|
40 |
pool = redis.ConnectionPool.from_url("redis://localhost")
|
41 |
r = redis.Redis.from_pool(pool)
|
42 |
|
@@ -127,6 +130,18 @@ async def __remove_temp(request):
|
|
127 |
|
128 |
return PlainTextResponse("", 200)
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
def __convert2md(inp):
|
131 |
# Use gfm-raw_html to strip styling data from source file
|
132 |
return pypandoc.convert_text(inp, "gfm-raw_html", "html")
|
|
|
37 |
|
38 |
import redis.asyncio as redis
|
39 |
|
40 |
+
import asyncio
|
41 |
+
import subprocess
|
42 |
+
|
43 |
pool = redis.ConnectionPool.from_url("redis://localhost")
|
44 |
r = redis.Redis.from_pool(pool)
|
45 |
|
|
|
130 |
|
131 |
return PlainTextResponse("", 200)
|
132 |
|
133 |
+
def __convert_text(input, type_in, type_out):
|
134 |
+
|
135 |
+
# Create a subprocess
|
136 |
+
process = await asyncio.create_subprocess_exec(
|
137 |
+
'pandoc', '-t', 'html', # command to execute
|
138 |
+
stdout=asyncio.subprocess.PIPE, # redirect stdout
|
139 |
+
stderr=asyncio.subprocess.STDOUT,
|
140 |
+
stdin=asyncio.subprocess.PIPE,# redirect stderr
|
141 |
+
)
|
142 |
+
stdout, _ = await process.communicate(input=input.encode())
|
143 |
+
print(stdout.decode())
|
144 |
+
|
145 |
def __convert2md(inp):
|
146 |
# Use gfm-raw_html to strip styling data from source file
|
147 |
return pypandoc.convert_text(inp, "gfm-raw_html", "html")
|