Spaces:
Sleeping
Sleeping
File size: 976 Bytes
918b834 8e8f958 de1f576 85550bb d5481c1 8e8f958 918b834 bb4c477 8e8f958 de1f576 8e8f958 46f2661 8e8f958 918b834 bb4c477 918b834 |
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 30 31 32 33 34 35 36 37 38 39 40 |
import gradio as gr
import os
import subprocess
folder_path = 'src/server'
file_name = 'main.cs'
file_path = os.path.join(folder_path, file_name)
os.makedirs(folder_path, exist_ok=True)
open('roblox-cs.yml', 'w').write("""SourceFolder: src
OutputFolder: dist
EmitNativeAttributeOnClassOrNamespaceCallbacks: true
EnabledBuiltInTransformers:
- Debug
CSharpOptions:
EntryPointRequired: false
EntryPointName: Game
MainMethodName: Main
AssemblyName: ExampleProject""")
def compile(cs):
# Create file
with open(file_path, 'w') as file:
file.write(cs)
# Run command
try:
result = subprocess.run(
['dotnet', 'run'],
capture_output=True,
text=True,
check=True
)
except subprocess.CalledProcessError as e:
gr.Error(f"Error: `{e.stderr}`, Exit Status: {e.returncode}")
return 'ha'
demo = gr.Interface(fn=compile, inputs="text", outputs="text")
demo.launch()
|