Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
|
|
| 1 |
from flask import Flask, render_template, request, redirect, url_for
|
| 2 |
|
| 3 |
app = Flask(__name__)
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
"admin": "password123", # username: password
|
| 8 |
-
"user1": "mypassword"
|
| 9 |
-
}
|
| 10 |
|
| 11 |
@app.route('/')
|
| 12 |
-
def
|
| 13 |
-
return render_template('
|
| 14 |
|
| 15 |
-
@app.route('/
|
| 16 |
def login():
|
| 17 |
-
username = request.form
|
| 18 |
-
password = request.form
|
| 19 |
-
|
| 20 |
-
if username
|
| 21 |
-
return redirect(url_for('
|
| 22 |
else:
|
| 23 |
-
|
| 24 |
-
return render_template('index.html', error=error)
|
| 25 |
|
| 26 |
-
|
| 27 |
-
def
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
if __name__ == '__main__':
|
| 31 |
app.run(debug=True)
|
| 32 |
-
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from flask import Flask, render_template, request, redirect, url_for
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
| 5 |
|
| 6 |
+
# Sample username and password for login
|
| 7 |
+
USER_CREDENTIALS = {"username": "user", "password": "pass"}
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
@app.route('/')
|
| 10 |
+
def home():
|
| 11 |
+
return render_template('login.html')
|
| 12 |
|
| 13 |
+
@app.route('/login', methods=['POST'])
|
| 14 |
def login():
|
| 15 |
+
username = request.form['username']
|
| 16 |
+
password = request.form['password']
|
| 17 |
+
|
| 18 |
+
if username == USER_CREDENTIALS["username"] and password == USER_CREDENTIALS["password"]:
|
| 19 |
+
return redirect(url_for('gradio_app'))
|
| 20 |
else:
|
| 21 |
+
return "Invalid credentials, please try again."
|
|
|
|
| 22 |
|
| 23 |
+
def gradio_app():
|
| 24 |
+
def greet(name):
|
| 25 |
+
return f"Hello, {name}!"
|
| 26 |
+
|
| 27 |
+
interface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 28 |
+
interface.launch()
|
| 29 |
|
| 30 |
if __name__ == '__main__':
|
| 31 |
app.run(debug=True)
|
|
|