random users and api
This commit is contained in:
parent
b73a0da47e
commit
ec61312302
14
app.py
14
app.py
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
import random
|
||||
from flask import Flask, redirect, render_template
|
||||
from waitress import serve
|
||||
|
||||
|
@ -40,13 +41,22 @@ def getUserWebsite(name):
|
|||
return render_template('404.html'), 404
|
||||
return redirect(websites[users.index(name)])
|
||||
|
||||
|
||||
@app.route("/users")
|
||||
def listUsers():
|
||||
thingToGive = ""
|
||||
for user in users:
|
||||
thingToGive = thingToGive + f"<a href=\"{websites[users.index(user)]}\" target=\"_blank\">{user}</a><br>"
|
||||
return "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/css/users.css\"></head><body>"+ thingToGive+"<body><html>"
|
||||
return "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/css/users.css\"></head><body>"+ thingToGive+"</body></html>"
|
||||
|
||||
@app.route("/random")
|
||||
def getRandomUser():
|
||||
randomNumber = random.randint(0, len(users) -1 )
|
||||
return redirect(websites[randomNumber])
|
||||
|
||||
|
||||
@app.route("/api")
|
||||
def getJson():
|
||||
return data
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
|
|
Loading…
Reference in New Issue