Spaces:
Runtime error
Runtime error
Commit
·
ac83549
1
Parent(s):
bc4ae4a
test
Browse files- Dockerfile +1 -1
- main.py +17 -4
Dockerfile
CHANGED
|
@@ -8,4 +8,4 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
| 8 |
|
| 9 |
COPY . .
|
| 10 |
|
| 11 |
-
CMD ["gunicorn","-b", "0.0.0.0:7860", "main:app"]
|
|
|
|
| 8 |
|
| 9 |
COPY . .
|
| 10 |
|
| 11 |
+
CMD ["gunicorn","-b", "0.0.0.0:7860", "main:app"]
|
main.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, request, abort
|
| 2 |
|
| 3 |
import markdown
|
| 4 |
from bs4 import BeautifulSoup
|
|
@@ -23,6 +23,7 @@ from linebot.v3.webhooks import (
|
|
| 23 |
|
| 24 |
import os
|
| 25 |
import requests
|
|
|
|
| 26 |
|
| 27 |
HF_TOKEN = os.environ.get('HF_TOKEN')
|
| 28 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
|
@@ -33,8 +34,16 @@ def query(payload):
|
|
| 33 |
|
| 34 |
app = Flask(__name__)
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
@app.route("/")
|
| 40 |
def home():
|
|
@@ -70,4 +79,8 @@ def handle_message(event):
|
|
| 70 |
reply_token=event.reply_token,
|
| 71 |
messages=[TextMessage(text=soup.get_text())]
|
| 72 |
)
|
| 73 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, request, abort, send_from_directory
|
| 2 |
|
| 3 |
import markdown
|
| 4 |
from bs4 import BeautifulSoup
|
|
|
|
| 23 |
|
| 24 |
import os
|
| 25 |
import requests
|
| 26 |
+
import logging
|
| 27 |
|
| 28 |
HF_TOKEN = os.environ.get('HF_TOKEN')
|
| 29 |
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
|
|
|
|
| 34 |
|
| 35 |
app = Flask(__name__)
|
| 36 |
|
| 37 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 38 |
+
app.logger.setLevel(logging.INFO)
|
| 39 |
+
|
| 40 |
+
channel_secret = os.getenv('YOUR_CHANNEL_SECRET', None)
|
| 41 |
+
channel_access_token = os.getenv('YOUR_CHANNEL_ACCESS_TOKEN', None)
|
| 42 |
+
|
| 43 |
+
handler = WebhookHandler(channel_secret)
|
| 44 |
+
configuration = Configuration(
|
| 45 |
+
access_token=channel_access_token
|
| 46 |
+
)
|
| 47 |
|
| 48 |
@app.route("/")
|
| 49 |
def home():
|
|
|
|
| 79 |
reply_token=event.reply_token,
|
| 80 |
messages=[TextMessage(text=soup.get_text())]
|
| 81 |
)
|
| 82 |
+
)
|
| 83 |
+
|
| 84 |
+
@app.route('/static/<path:path>')
|
| 85 |
+
def send_static_content(path):
|
| 86 |
+
return send_from_directory('static', path)
|