Spaces:
Sleeping
Sleeping
Update types.py
Browse files
types.py
CHANGED
@@ -1,37 +1,70 @@
|
|
1 |
class Code:
|
2 |
-
def __init__(self, code
|
3 |
-
self.
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
class AppType:
|
7 |
-
def __init__(self, app_type: str
|
|
|
8 |
|
9 |
class File:
|
10 |
-
def
|
11 |
-
self.path = path
|
|
|
12 |
|
13 |
-
class Space
|
14 |
def __init__(self, space: str):
|
15 |
self.space = space
|
16 |
|
17 |
class Tutorial:
|
18 |
-
__init__(self, tutorial: str):
|
19 |
self.tutorial = tutorial
|
20 |
|
21 |
class App:
|
22 |
-
def __init__(self, code: Code, app_type:
|
23 |
-
self. =
|
24 |
-
self. =
|
|
|
25 |
self.tutorial = tutorial
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
|
|
29 |
|
30 |
-
class
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
class StreamlitApp(App):
|
34 |
-
|
|
|
|
|
35 |
|
36 |
class ReactApp(App):
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
class Code:
|
2 |
+
def __init__(self, code: str, language: str):
|
3 |
+
self.code = code
|
4 |
+
self.language = language
|
5 |
+
|
6 |
+
class Prompt:
|
7 |
+
def __init__(self, prompt: str):
|
8 |
+
self.prompt = prompt
|
9 |
|
10 |
class AppType:
|
11 |
+
def __init__(self, app_type: str):
|
12 |
+
self.app_type = app_type
|
13 |
|
14 |
class File:
|
15 |
+
def __init__(self, path: str, content: str):
|
16 |
+
self.path = path
|
17 |
+
self.content = content
|
18 |
|
19 |
+
class Space:
|
20 |
def __init__(self, space: str):
|
21 |
self.space = space
|
22 |
|
23 |
class Tutorial:
|
24 |
+
def __init__(self, tutorial: str):
|
25 |
self.tutorial = tutorial
|
26 |
|
27 |
class App:
|
28 |
+
def __init__(self, code: Code, app_type: AppType, space: Space, tutorial: Tutorial):
|
29 |
+
self.code = code
|
30 |
+
self.app_type = app_type
|
31 |
+
self.space = space
|
32 |
self.tutorial = tutorial
|
33 |
+
self._id = None
|
34 |
+
|
35 |
+
def generate_id(self):
|
36 |
+
# Simple id generation for demonstration purposes
|
37 |
+
return f"app-{id(self)}"
|
38 |
|
39 |
+
def launch(self):
|
40 |
+
# Simulate launching the app
|
41 |
+
print(f"Launching app {self._id}...")
|
42 |
|
43 |
+
class WebApp(App):
|
44 |
+
def __init__(self, code: Code, app_type: AppType, space: Space, tutorial: Tutorial):
|
45 |
+
super().__init__(code, app_type, space, tutorial)
|
46 |
+
self._id = self.generate_id()
|
47 |
+
|
48 |
+
class GradioApp(App):
|
49 |
+
def __init__(self, code: Code, app_type: AppType, space: Space, tutorial: Tutorial):
|
50 |
+
super().__init__(code, app_type, space, tutorial)
|
51 |
+
self._id = self.generate_id()
|
52 |
|
53 |
class StreamlitApp(App):
|
54 |
+
def __init__(self, code: Code, app_type: AppType, space: Space, tutorial: Tutorial):
|
55 |
+
super().__init__(code, app_type, space, tutorial)
|
56 |
+
self._id = self.generate_id()
|
57 |
|
58 |
class ReactApp(App):
|
59 |
+
def __init__(self, code: Code, app_type: AppType, space: Space, tutorial: Tutorial):
|
60 |
+
super().__init__(code, app_type, space, tutorial)
|
61 |
+
self._id = self.generate_id()
|
62 |
+
|
63 |
+
# Example usage
|
64 |
+
code = Code("example code", "python")
|
65 |
+
app_type = AppType("web")
|
66 |
+
space = Space("example space")
|
67 |
+
tutorial = Tutorial("example tutorial")
|
68 |
+
|
69 |
+
app = WebApp(code, app_type, space, tutorial)
|
70 |
+
app.launch()
|