Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,19 @@ import os
|
|
| 5 |
import re
|
| 6 |
import emoji
|
| 7 |
from urllib.parse import unquote
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
def filter_text_and_preserve_emojis(text):
|
| 9 |
# Regular expression that allows letters, numbers, spaces, specific punctuation, and a broad range of Unicode characters for emojis
|
| 10 |
pattern = re.compile(r'[a-zA-Z0-9\s.,?!\'"]|[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F700-\U0001F77F\U0001F780-\U0001F7FF\U0001F800-\U0001F8FF\U0001F900-\U0001F9FF\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF\U00002702-\U000027B0\U000024C2-\U0001F251]+')
|
|
@@ -148,3 +161,6 @@ with gr.Blocks(css=".gradio-app { background-color: #123456; }") as demo:
|
|
| 148 |
gr.Button("Process").click(process_second_life_input, inputs=[input_text], outputs=[output_text])
|
| 149 |
|
| 150 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
import re
|
| 6 |
import emoji
|
| 7 |
from urllib.parse import unquote
|
| 8 |
+
from flask import Flask, request, jsonify
|
| 9 |
+
from gradio_client import Client
|
| 10 |
+
|
| 11 |
+
app = Flask(__name__)
|
| 12 |
+
client = Client("https://aeuph-hive-menu.hf.space/")
|
| 13 |
+
|
| 14 |
+
@app.route("/send_to_gradio", methods=["POST"])
|
| 15 |
+
def send_to_gradio():
|
| 16 |
+
data = request.json
|
| 17 |
+
message = data.get("message", "")
|
| 18 |
+
result = client.predict(message, fn_index=0)
|
| 19 |
+
return jsonify(result)
|
| 20 |
+
|
| 21 |
def filter_text_and_preserve_emojis(text):
|
| 22 |
# Regular expression that allows letters, numbers, spaces, specific punctuation, and a broad range of Unicode characters for emojis
|
| 23 |
pattern = re.compile(r'[a-zA-Z0-9\s.,?!\'"]|[\U0001F600-\U0001F64F\U0001F300-\U0001F5FF\U0001F680-\U0001F6FF\U0001F700-\U0001F77F\U0001F780-\U0001F7FF\U0001F800-\U0001F8FF\U0001F900-\U0001F9FF\U0001FA00-\U0001FA6F\U0001FA70-\U0001FAFF\U00002702-\U000027B0\U000024C2-\U0001F251]+')
|
|
|
|
| 161 |
gr.Button("Process").click(process_second_life_input, inputs=[input_text], outputs=[output_text])
|
| 162 |
|
| 163 |
demo.launch()
|
| 164 |
+
|
| 165 |
+
if __name__ == "__main__":
|
| 166 |
+
app.run(debug=True)
|