Spaces:
Sleeping
Sleeping
DmitrMakeev
commited on
Commit
•
40c4f6f
1
Parent(s):
6f56341
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from flask import Flask, request, render_template_string, jsonify
|
2 |
from flask import render_template
|
3 |
import sqlite3
|
4 |
import os
|
@@ -14,6 +14,20 @@ from whatsapp_api_webhook_server_python.webhooksHandler import startServer
|
|
14 |
|
15 |
app = Flask(__name__, template_folder="./")
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
# Создание базы данных и таблицы
|
18 |
def init_db():
|
19 |
try:
|
@@ -65,11 +79,40 @@ def se_mes_im():
|
|
65 |
return render_template('se_mes_im.html')
|
66 |
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
|
70 |
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
|
|
|
|
|
|
73 |
|
74 |
|
75 |
|
|
|
1 |
+
from flask import Flask, request, render_template_string, send_from_directory, jsonify
|
2 |
from flask import render_template
|
3 |
import sqlite3
|
4 |
import os
|
|
|
14 |
|
15 |
app = Flask(__name__, template_folder="./")
|
16 |
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
app.config['UPLOAD_FOLDER'] = 'static'
|
21 |
+
IMAGE_FILENAME = 'latest_image.jpg'
|
22 |
+
|
23 |
+
# Создание директории, если она не существует
|
24 |
+
if not os.path.exists(app.config['UPLOAD_FOLDER']):
|
25 |
+
os.makedirs(app.config['UPLOAD_FOLDER'])
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
# Создание базы данных и таблицы
|
32 |
def init_db():
|
33 |
try:
|
|
|
79 |
return render_template('se_mes_im.html')
|
80 |
|
81 |
|
82 |
+
@app.route('/se_mes_im2', methods=['GET'])
|
83 |
+
def se_mes_im2():
|
84 |
+
return render_template('se_mes_im2.html')
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
+
@app.route('/upload', methods=['POST'])
|
102 |
+
def upload_file():
|
103 |
+
if 'photo' not in request.files:
|
104 |
+
return "No file part", 400
|
105 |
+
file = request.files['photo']
|
106 |
+
if file.filename == '':
|
107 |
+
return "No selected file", 400
|
108 |
+
save_path = os.path.join(app.config['UPLOAD_FOLDER'], IMAGE_FILENAME)
|
109 |
+
file.save(save_path)
|
110 |
+
file_url = f"/{app.config['UPLOAD_FOLDER']}/{IMAGE_FILENAME}"
|
111 |
+
return file_url, 200
|
112 |
|
113 |
+
@app.route('/image', methods=['GET'])
|
114 |
+
def get_image():
|
115 |
+
return send_from_directory(app.config['UPLOAD_FOLDER'], IMAGE_FILENAME)
|
116 |
|
117 |
|
118 |
|