random users and api

This commit is contained in:
Gnawmon 2024-04-18 23:02:44 +03:00
parent b73a0da47e
commit ec61312302
1 changed files with 12 additions and 2 deletions

14
app.py
View File

@ -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():