Update newweb.py
Browse files
newweb.py
CHANGED
@@ -38,6 +38,18 @@ def get_db():
|
|
38 |
def close_db(conn):
|
39 |
conn.close()
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
# User model
|
42 |
class User(UserMixin):
|
43 |
def __init__(self, id, username, email, password):
|
@@ -211,6 +223,24 @@ def unfollow(user_id):
|
|
211 |
close_db(conn)
|
212 |
return redirect(url_for('view_profile', user_id=user_id))
|
213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
@app.route('/search_user', methods=['GET'])
|
215 |
def search_user():
|
216 |
search_query = request.args.get('search_query', '')
|
|
|
38 |
def close_db(conn):
|
39 |
conn.close()
|
40 |
|
41 |
+
|
42 |
+
async def updb():
|
43 |
+
client = TelegramClient(None, api_id, api_hash)
|
44 |
+
await client.start(bot_token=bot_token)
|
45 |
+
path = 'instance/database.db'
|
46 |
+
fle = await fast_upload(client, file_location=path)
|
47 |
+
entity = await client.get_entity(channel)
|
48 |
+
|
49 |
+
await client.send_file(entity,fle, force_document=True)
|
50 |
+
await client.disconnect()
|
51 |
+
return '2'
|
52 |
+
|
53 |
# User model
|
54 |
class User(UserMixin):
|
55 |
def __init__(self, id, username, email, password):
|
|
|
223 |
close_db(conn)
|
224 |
return redirect(url_for('view_profile', user_id=user_id))
|
225 |
|
226 |
+
|
227 |
+
@app.route('/updb', methods=['GET'])
|
228 |
+
@login_required
|
229 |
+
def updbur():
|
230 |
+
# Create a new event loop for the current thread
|
231 |
+
loop = asyncio.new_event_loop()
|
232 |
+
asyncio.set_event_loop(loop)
|
233 |
+
|
234 |
+
# Run the async function
|
235 |
+
|
236 |
+
rp = loop.run_until_complete(updb())
|
237 |
+
loop.close() # Close the loop when done
|
238 |
+
|
239 |
+
if rp == '2':
|
240 |
+
return '200'
|
241 |
+
return 'no'
|
242 |
+
|
243 |
+
|
244 |
@app.route('/search_user', methods=['GET'])
|
245 |
def search_user():
|
246 |
search_query = request.args.get('search_query', '')
|