Spaces:
Running
Running
Update run_app.py
Browse files- run_app.py +33 -25
run_app.py
CHANGED
@@ -1,32 +1,40 @@
|
|
1 |
-
import
|
2 |
-
from gradio_auth import Auth
|
3 |
import subprocess
|
|
|
4 |
|
5 |
-
|
6 |
-
USERNAME = "your_username"
|
7 |
-
PASSWORD = "your_password"
|
8 |
|
9 |
-
#
|
10 |
-
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
server_port=7860,
|
28 |
-
prevent_thread_lock=True
|
29 |
-
)
|
30 |
|
31 |
-
|
32 |
-
subprocess.run(["python", "app_w_lora.py"])
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, redirect, url_for, render_template_string
|
|
|
2 |
import subprocess
|
3 |
+
import threading
|
4 |
|
5 |
+
app = Flask(__name__)
|
|
|
|
|
6 |
|
7 |
+
# Replace these with your desired username and password
|
8 |
+
USERNAME = 'your_username'
|
9 |
+
PASSWORD = 'your_password'
|
10 |
|
11 |
+
html_login = '''
|
12 |
+
<!doctype html>
|
13 |
+
<title>Login</title>
|
14 |
+
<h1>Login</h1>
|
15 |
+
<form method=post>
|
16 |
+
<input type=text name=username placeholder='Username'>
|
17 |
+
<input type=password name=password placeholder='Password'>
|
18 |
+
<input type=submit value=Login>
|
19 |
+
</form>
|
20 |
+
'''
|
21 |
|
22 |
+
@app.route('/', methods=['GET', 'POST'])
|
23 |
+
def login():
|
24 |
+
if request.method == 'POST':
|
25 |
+
if request.form['username'] == USERNAME and request.form['password'] == PASSWORD:
|
26 |
+
return redirect(url_for('gradio_app'))
|
27 |
+
else:
|
28 |
+
return 'Incorrect credentials', 401
|
29 |
+
return render_template_string(html_login)
|
30 |
|
31 |
+
@app.route('/gradio')
|
32 |
+
def gradio_app():
|
33 |
+
return redirect("http://localhost:7860")
|
|
|
|
|
|
|
34 |
|
35 |
+
def run_gradio():
|
36 |
+
subprocess.run(["python", "app_w_lora.py"])
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
39 |
+
threading.Thread(target=run_gradio).start()
|
40 |
+
app.run(host='0.0.0.0', port=5000)
|