Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import random
|
|
6 |
from pydantic import BaseModel
|
7 |
from fastapi import FastAPI
|
8 |
from jinja2 import Environment, FileSystemLoader
|
9 |
-
|
10 |
app = FastAPI()
|
11 |
|
12 |
class HtmlInput(BaseModel):
|
@@ -94,15 +94,13 @@ async def mainFunction(html_content:str):
|
|
94 |
if not os.path.exists('json'):
|
95 |
os.makedirs('json')
|
96 |
|
97 |
-
filename = 'sample.html'
|
98 |
-
|
99 |
# Write the HTML string to the file
|
100 |
-
|
101 |
-
file.write(html_content)
|
102 |
print("html file created")
|
103 |
template_loader = FileSystemLoader(searchpath=".")
|
104 |
template_env = Environment(loader=template_loader)
|
105 |
-
template = template_env.
|
|
|
106 |
|
107 |
# Load JSON data from files
|
108 |
with open("modified_data.json", "r", encoding="utf-8") as universal_file:
|
|
|
6 |
from pydantic import BaseModel
|
7 |
from fastapi import FastAPI
|
8 |
from jinja2 import Environment, FileSystemLoader
|
9 |
+
import io
|
10 |
app = FastAPI()
|
11 |
|
12 |
class HtmlInput(BaseModel):
|
|
|
94 |
if not os.path.exists('json'):
|
95 |
os.makedirs('json')
|
96 |
|
|
|
|
|
97 |
# Write the HTML string to the file
|
98 |
+
html_file = io.StringIO(html_content)
|
|
|
99 |
print("html file created")
|
100 |
template_loader = FileSystemLoader(searchpath=".")
|
101 |
template_env = Environment(loader=template_loader)
|
102 |
+
template = template_env.from_string(html_file.getvalue())
|
103 |
+
print("Template rendered successfully")
|
104 |
|
105 |
# Load JSON data from files
|
106 |
with open("modified_data.json", "r", encoding="utf-8") as universal_file:
|