Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,40 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
folder_path = 'src/server'
|
3 |
file_name = 'main.cs'
|
4 |
file_path = os.path.join(folder_path, file_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
def compile(cs):
|
|
|
7 |
os.makedirs(folder_path, exist_ok=True)
|
8 |
|
9 |
with open(file_path, 'w') as file:
|
10 |
file.write(cs)
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
demo = gr.Interface(fn=compile, inputs="text", outputs="text")
|
14 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
+
import subprocess
|
4 |
+
|
5 |
folder_path = 'src/server'
|
6 |
file_name = 'main.cs'
|
7 |
file_path = os.path.join(folder_path, file_name)
|
8 |
+
open('roblox-cs.yml', """SourceFolder: src
|
9 |
+
OutputFolder: dist
|
10 |
+
EmitNativeAttributeOnClassOrNamespaceCallbacks: true
|
11 |
+
EnabledBuiltInTransformers:
|
12 |
+
- Debug
|
13 |
+
CSharpOptions:
|
14 |
+
EntryPointRequired: false
|
15 |
+
EntryPointName: Game
|
16 |
+
MainMethodName: Main
|
17 |
+
AssemblyName: ExampleProject""")
|
18 |
|
19 |
def compile(cs):
|
20 |
+
# Create file
|
21 |
os.makedirs(folder_path, exist_ok=True)
|
22 |
|
23 |
with open(file_path, 'w') as file:
|
24 |
file.write(cs)
|
25 |
+
|
26 |
+
# Run command
|
27 |
+
try:
|
28 |
+
result = subprocess.run(
|
29 |
+
['dotnet', 'run']
|
30 |
+
capture_output=True,
|
31 |
+
text=True,
|
32 |
+
check=True
|
33 |
+
)
|
34 |
+
except subprocess.CalledProcessError as e:
|
35 |
+
gr.Error(f"Error: `{e.stderr}`, Exit Status: {e.returncode}")
|
36 |
+
|
37 |
+
return 'ha'
|
38 |
|
39 |
demo = gr.Interface(fn=compile, inputs="text", outputs="text")
|
40 |
demo.launch()
|