ricklon commited on
Commit
1ab9eb6
·
1 Parent(s): 0d4acc0

adding main code

Browse files
Files changed (1) hide show
  1. app.py +65 -5
app.py CHANGED
@@ -1,9 +1,69 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
7
 
8
- if __name__ == "__main__":
9
- demo.launch(show_api=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from svgwrite import Drawing
3
 
4
+ def create_postcard(name, tagline, description, events, location, hours, contact, call_to_action):
5
+ # Create a new SVG drawing
6
+ dwg = Drawing(size=("200mm", "100mm"))
7
 
8
+ # Assume the logo is a PIL Image; convert to base64 to embed in SVG
9
+ if logo is not None:
10
+ import base64
11
+ from io import BytesIO
12
+ buffer = BytesIO()
13
+ logo.save(buffer, format="PNG")
14
+ logo_base64 = base64.b64encode(buffer.getvalue()).decode('utf-8')
15
+ dwg.add(dwg.image(href=f"data:image/png;base64,{logo_base64}", insert=("10mm", "10mm"), size=("50mm", "50mm")))
16
 
17
+
18
+ # Define text styles
19
+ header_style = "font-size:18px; font-weight:bold;"
20
+ subheader_style = "font-size:12px;"
21
+ text_style = "font-size:10px;"
22
+
23
+ # Add the Makerspace name
24
+ dwg.add(dwg.text(name, insert=("10mm", "15mm"), style=header_style))
25
+
26
+ # Add the tagline
27
+ dwg.add(dwg.text(tagline, insert=("10mm", "25mm"), style=subheader_style))
28
+
29
+ # Add a rectangle for the CTA
30
+ dwg.add(dwg.rect(insert=("150mm", "80mm"), size=("40mm", "15mm"), rx="2mm", fill="#FFD700"))
31
+ dwg.add(dwg.text(call_to_action, insert=("155mm", "90mm"), style=header_style))
32
+
33
+ # Add description, events, and other information
34
+ # ...
35
+
36
+ # For QR Code: You'll need to use a QR Code generator library to create a QR code
37
+ # and then convert it to SVG to include it here.
38
+ # ...
39
+
40
+ # Save the SVG to a file
41
+ svg_output = name.replace(" ", "_").lower() + "_postcard.svg"
42
+ dwg.saveas(svg_output)
43
+
44
+ return svg_output
45
+
46
+
47
+
48
+ # Define your Gradio interface
49
+ iface = gr.Interface(
50
+ fn=create_postcard,
51
+ inputs=[
52
+ gr.Textbox(label="Makerspace Name"),
53
+ gr.Textbox(label="Tagline or Mission Statement"),
54
+ gr.Textarea(label="Description of Services"),
55
+ gr.Textarea(label="Upcoming Events"),
56
+ gr.Textbox(label="Location"),
57
+ gr.Textbox(label="Hours of Operation"),
58
+ gr.Textbox(label="Contact Information"),
59
+ gr.Textbox(label="Call to Action"),
60
+ gr.Image(label="Upload Logo", type="pil", tool="select") # Accepts image uploads
61
+
62
+ ],
63
+ outputs="file",
64
+ title="Makerspace Postcard Creator",
65
+ description="Fill out the details to create a postcard for your makerspace."
66
+ )
67
+
68
+ # Run the interface
69
+ iface.launch()