Spaces:
Sleeping

imgar commited on
Commit
fa795df
·
1 Parent(s): 90dbd6d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ # Handy constants
5
+ PHOTOPEA_MAIN_URL = "https://www.photopea.com/"
6
+ PHOTOPEA_IFRAME_ID = "webui-photopea-iframe"
7
+ PHOTOPEA_IFRAME_HEIGHT = 768
8
+ PHOTOPEA_IFRAME_WIDTH = "100%"
9
+ PHOTOPEA_IFRAME_LOADED_EVENT = "onPhotopeaLoaded"
10
+
11
+ def get_photopea_url_params():
12
+ return "#%7B%22resources%22:%5B%22data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIAAQMAAADOtka5AAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAANQTFRF////p8QbyAAAADZJREFUeJztwQEBAAAAgiD/r25IQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfBuCAAAB0niJ8AAAAABJRU5ErkJggg==%22%5D%7D"
13
+
14
+
15
+
16
+ with gr.Blocks(css="./style.css", title="[ Free Web ] Photoshop") as demo:
17
+ with gr.Row():
18
+ # Add an iframe with Photopea directly in the tab.
19
+ gr.HTML(
20
+ f"""
21
+ <iframe id='{PHOTOPEA_IFRAME_ID}'
22
+ src = '{PHOTOPEA_MAIN_URL}{get_photopea_url_params()}'
23
+ width = '{PHOTOPEA_IFRAME_WIDTH}'
24
+ height = '{PHOTOPEA_IFRAME_HEIGHT}'
25
+ onload = '{PHOTOPEA_IFRAME_LOADED_EVENT}(this)'
26
+ style='overflow-y: hidden;'
27
+ >
28
+ """
29
+ )
30
+
31
+
32
+
33
+ demo.launch()