Jaswanth-Dev commited on
Commit
f983c19
1 Parent(s): 2a2a576

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -1,16 +1,23 @@
1
  import streamlit as st
2
  import requests
3
  import json
4
-
 
5
 
6
  ngrok_url = st.text_input("ngrok url")
7
  prompt_input = st.text_input("Prompt")
8
 
9
- payload = json.dumps({"text":prompt_input})
10
- headers = {
11
- 'Content-Type': 'text/plain'
12
- }
 
13
 
14
- response = requests.request("POST", ngrok_url, headers=headers, data=payload)
 
 
 
 
15
 
16
- print(response.text)
 
 
1
  import streamlit as st
2
  import requests
3
  import json
4
+ from PIL import Image
5
+ import time
6
 
7
  ngrok_url = st.text_input("ngrok url")
8
  prompt_input = st.text_input("Prompt")
9
 
10
+ if st.button('Generate Image'):
11
+ payload = json.dumps({"text":prompt_input})
12
+ headers = {
13
+ 'Content-Type': 'text/plain'
14
+ }
15
 
16
+ response = requests.request("POST", ngrok_url, headers=headers, data=payload)
17
+ file_name = "static/"+prompt_input+time.strftime("%Y%m%d-%H%M%S")+".png"
18
+
19
+ save_file = open(file_name, "wb")
20
+ save_file.write(response.content)
21
 
22
+ image = Image.open(file_name)
23
+ st.image(image, caption=prompt_input)