Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ import os
|
|
7 |
from werkzeug.utils import secure_filename
|
8 |
import string
|
9 |
|
10 |
-
|
11 |
imgtoken = "token 72ec00483379076f580eb8126f29da802a5140c3"
|
12 |
imgtoken2 = "token d128e752adc1f28aa91f63decc1c09d667585dde"
|
13 |
|
@@ -109,7 +108,6 @@ def generate_image(prompt):
|
|
109 |
|
110 |
|
111 |
|
112 |
-
url3 = "https://api.braininc.net/be/vectordb/indexers/"
|
113 |
url2 = "https://api.braininc.net/stream/bas-demo-v4/nlp/completions_generation"
|
114 |
headers = {
|
115 |
"Authorization": f"{imgtoken}",
|
@@ -124,8 +122,7 @@ headers2 = {
|
|
124 |
with open('image.json', 'r') as file:
|
125 |
images = file.read()
|
126 |
|
127 |
-
|
128 |
-
user_name = []
|
129 |
|
130 |
############################## GITHUB DATABASE ##############################################
|
131 |
|
@@ -137,7 +134,7 @@ if not os.path.exists(app.config['UPLOAD_FOLDER']):
|
|
137 |
|
138 |
def generate_token():
|
139 |
token2 = "ALEX-9-LY"
|
140 |
-
characters = string.ascii_letters + string.digits
|
141 |
for _ in range(22):
|
142 |
token2 += random.choice(characters)
|
143 |
return token2
|
@@ -299,6 +296,49 @@ def process_account_action(action, account_username, password, first_name=None,
|
|
299 |
|
300 |
################ LOGIN #################################
|
301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
@app.route("/login", methods=["GET", "POST"])
|
303 |
def login():
|
304 |
# Check if device info matches any stored device info
|
|
|
7 |
from werkzeug.utils import secure_filename
|
8 |
import string
|
9 |
|
|
|
10 |
imgtoken = "token 72ec00483379076f580eb8126f29da802a5140c3"
|
11 |
imgtoken2 = "token d128e752adc1f28aa91f63decc1c09d667585dde"
|
12 |
|
|
|
108 |
|
109 |
|
110 |
|
|
|
111 |
url2 = "https://api.braininc.net/stream/bas-demo-v4/nlp/completions_generation"
|
112 |
headers = {
|
113 |
"Authorization": f"{imgtoken}",
|
|
|
122 |
with open('image.json', 'r') as file:
|
123 |
images = file.read()
|
124 |
|
125 |
+
|
|
|
126 |
|
127 |
############################## GITHUB DATABASE ##############################################
|
128 |
|
|
|
134 |
|
135 |
def generate_token():
|
136 |
token2 = "ALEX-9-LY"
|
137 |
+
characters = string.ascii_letters + string.digits
|
138 |
for _ in range(22):
|
139 |
token2 += random.choice(characters)
|
140 |
return token2
|
|
|
296 |
|
297 |
################ LOGIN #################################
|
298 |
|
299 |
+
@app.route("/sign-up", methods=["GET", "POST"])
|
300 |
+
def create_account():
|
301 |
+
if request.method == 'POST':
|
302 |
+
first_name = request.form['first_name']
|
303 |
+
last_name = request.form['last_name']
|
304 |
+
account_username = request.form['username']
|
305 |
+
password = request.form['password']
|
306 |
+
|
307 |
+
# Handling file upload
|
308 |
+
if 'profile_image' not in request.files:
|
309 |
+
flash('No file part')
|
310 |
+
return redirect(request.url)
|
311 |
+
file = request.files['profile_image']
|
312 |
+
if file.filename == '':
|
313 |
+
flash('No selected file')
|
314 |
+
return redirect(request.url)
|
315 |
+
if file:
|
316 |
+
filename = secure_filename(f"{account_username}.png")
|
317 |
+
file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
318 |
+
file.save(file_path)
|
319 |
+
|
320 |
+
result = process_account_action("create", account_username, password, first_name, last_name, file_path)
|
321 |
+
flash(result)
|
322 |
+
if "successfully" in result:
|
323 |
+
return redirect(url_for('login'))
|
324 |
+
|
325 |
+
return render_template('sign-up.html')
|
326 |
+
|
327 |
+
@app.route("/chat")
|
328 |
+
def chat():
|
329 |
+
if 'account_name' not in session or session['account_name'] is None:
|
330 |
+
return redirect(url_for('login'))
|
331 |
+
|
332 |
+
account_name = session.get("account_name")
|
333 |
+
first = session.get("first")
|
334 |
+
last = session.get("last")
|
335 |
+
token2 = session.get("token2")
|
336 |
+
greet = session.get("greet")
|
337 |
+
|
338 |
+
return render_template('ai-chat-bot.html', account_name=account_name, greet=greet, first=first, last=last, token2=token2)
|
339 |
+
|
340 |
+
|
341 |
+
|
342 |
@app.route("/login", methods=["GET", "POST"])
|
343 |
def login():
|
344 |
# Check if device info matches any stored device info
|