python flask cat generator api >.<
by - Thursday, January 1, 1970 at 12:00 AM
Simple cat pic/gif gen api with flask :3

download (anonfiles)

windows:
pip install flask
pip install requests
python3 api.py

debian/ubuntu:
apt install python3-pip
pip3 install flask
pip3 install requests
screen python3 api.py

pwease dont bully me if code is bad >.<
Arx &lt;3 Punk
Reply
Nice one, good job!
Reply
The cat is very cute, thanks for sharing
Reply
Very useful :D
Reply
That's awesome. Code looks fine as well!
Reply
I was looking for some more, thanks lol
Reply
I love python :pomhappy:

Cool lil flask project

also, don't let hardcoding become a bad habit

Change this
wandomgatos = ["gatos/cat.gif","gatos/cat1.gif","gatos/cat2.gif","gatos/cat3.gif","gatos/cat4.jpg","gatos/cat5.jpg","gatos/cat6.jpg","gatos/cat7.jpg","gatos/cat8.jpg","gatos/cat9.jpg","gatos/cat10.jpg","gatos/cat11.jpg","gatos/cat12.jpg","gatos/cat13.jpg","gatos/cat14.jpg","gatos/cat15.jpg","gatos/cat16.jpg","gatos/cat17.jpg","gatos/cat18.jpg"]

To this:
import glob
    wandomgatos = []
    for gato in glob.glob('gatos/*'):
        wandomgatos.append(gato)


[SPOILER=Implemented]
from flask import Flask,send_file
import random
import glob

app = Flask(__name__)

@app.route("/")
def index():
    return "Hewwo cat gen api go to /cat to generate :3"

@app.route("/cat")
def gato():
    wandomgatos = []
    for gato in glob.glob('gatos/*'):
        wandomgatos.append(gato)
    #wandomgatos = ["gatos/cat.gif","gatos/cat1.gif","gatos/cat2.gif","gatos/cat3.gif","gatos/cat4.jpg","gatos/cat5.jpg","gatos/cat6.jpg","gatos/cat7.jpg","gatos/cat8.jpg","gatos/cat9.jpg","gatos/cat10.jpg","gatos/cat11.jpg","gatos/cat12.jpg","gatos/cat13.jpg","gatos/cat14.jpg","gatos/cat15.jpg","gatos/cat16.jpg","gatos/cat17.jpg","gatos/cat18.jpg"]
    wandomchoice = random.choice(wandomgatos)
    return send_file(wandomchoice,mimetype="imagegif")

app.run(host="0.0.0.0",port=1337)


[/SPOILER]
Reply
(November 15, 2022, 11:07 PM)griimnak Wrote: I love python :pomhappy:

Cool lil flask project

also, don't let hardcoding become a bad habit

Change this
wandomgatos = ["gatos/cat.gif","gatos/cat1.gif","gatos/cat2.gif","gatos/cat3.gif","gatos/cat4.jpg","gatos/cat5.jpg","gatos/cat6.jpg","gatos/cat7.jpg","gatos/cat8.jpg","gatos/cat9.jpg","gatos/cat10.jpg","gatos/cat11.jpg","gatos/cat12.jpg","gatos/cat13.jpg","gatos/cat14.jpg","gatos/cat15.jpg","gatos/cat16.jpg","gatos/cat17.jpg","gatos/cat18.jpg"]

To this:
import glob
    wandomgatos = []
    for gato in glob.glob('gatos/*'):
        wandomgatos.append(gato)



[SPOILER=Implemented]
from flask import Flask,send_file
import random
import glob

app = Flask(__name__)

@app.route("/")
def index():
    return "Hewwo cat gen api go to /cat to generate :3"

@app.route("/cat")
def gato():
    wandomgatos = []
    for gato in glob.glob('gatos/*'):
        wandomgatos.append(gato)
    #wandomgatos = ["gatos/cat.gif","gatos/cat1.gif","gatos/cat2.gif","gatos/cat3.gif","gatos/cat4.jpg","gatos/cat5.jpg","gatos/cat6.jpg","gatos/cat7.jpg","gatos/cat8.jpg","gatos/cat9.jpg","gatos/cat10.jpg","gatos/cat11.jpg","gatos/cat12.jpg","gatos/cat13.jpg","gatos/cat14.jpg","gatos/cat15.jpg","gatos/cat16.jpg","gatos/cat17.jpg","gatos/cat18.jpg"]
    wandomchoice = random.choice(wandomgatos)
    return send_file(wandomchoice,mimetype="imagegif")

app.run(host="0.0.0.0",port=1337)



[/SPOILER]


    wandomgatos = [gato for gato in glob.glob('gatos/*')]
immediately no ?
Reply
(November 15, 2022, 11:38 PM)izouki Wrote:
(November 15, 2022, 11:07 PM)griimnak Wrote: I love python :pomhappy:

Cool lil flask project

also, don't let hardcoding become a bad habit

Change this
wandomgatos = ["gatos/cat.gif","gatos/cat1.gif","gatos/cat2.gif","gatos/cat3.gif","gatos/cat4.jpg","gatos/cat5.jpg","gatos/cat6.jpg","gatos/cat7.jpg","gatos/cat8.jpg","gatos/cat9.jpg","gatos/cat10.jpg","gatos/cat11.jpg","gatos/cat12.jpg","gatos/cat13.jpg","gatos/cat14.jpg","gatos/cat15.jpg","gatos/cat16.jpg","gatos/cat17.jpg","gatos/cat18.jpg"]

To this:
import glob
    wandomgatos = []
    for gato in glob.glob('gatos/*'):
        wandomgatos.append(gato)



[SPOILER=Implemented]
from flask import Flask,send_file
import random
import glob

app = Flask(__name__)

@app.route("/")
def index():
    return "Hewwo cat gen api go to /cat to generate :3"

@app.route("/cat")
def gato():
    wandomgatos = []
    for gato in glob.glob('gatos/*'):
        wandomgatos.append(gato)
    #wandomgatos = ["gatos/cat.gif","gatos/cat1.gif","gatos/cat2.gif","gatos/cat3.gif","gatos/cat4.jpg","gatos/cat5.jpg","gatos/cat6.jpg","gatos/cat7.jpg","gatos/cat8.jpg","gatos/cat9.jpg","gatos/cat10.jpg","gatos/cat11.jpg","gatos/cat12.jpg","gatos/cat13.jpg","gatos/cat14.jpg","gatos/cat15.jpg","gatos/cat16.jpg","gatos/cat17.jpg","gatos/cat18.jpg"]
    wandomchoice = random.choice(wandomgatos)
    return send_file(wandomchoice,mimetype="imagegif")

app.run(host="0.0.0.0",port=1337)



[/SPOILER]


    wandomgatos = [wandomgatos.append(gato) for gato in glob.glob('gatos/*')]
immediately no ?


Oh hell yeah, even better
sexy one liner
Reply
(November 15, 2022, 11:07 PM)griimnak Wrote: I love python :pomhappy:

Cool lil flask project

also, don't let hardcoding become a bad habit

Change this
wandomgatos = ["gatos/cat.gif","gatos/cat1.gif","gatos/cat2.gif","gatos/cat3.gif","gatos/cat4.jpg","gatos/cat5.jpg","gatos/cat6.jpg","gatos/cat7.jpg","gatos/cat8.jpg","gatos/cat9.jpg","gatos/cat10.jpg","gatos/cat11.jpg","gatos/cat12.jpg","gatos/cat13.jpg","gatos/cat14.jpg","gatos/cat15.jpg","gatos/cat16.jpg","gatos/cat17.jpg","gatos/cat18.jpg"]

To this:
import glob
    wandomgatos = []
    for gato in glob.glob('gatos/*'):
        wandomgatos.append(gato)



[SPOILER=Implemented]
from flask import Flask,send_file
import random
import glob

app = Flask(__name__)

@app.route("/")
def index():
    return "Hewwo cat gen api go to /cat to generate :3"

@app.route("/cat")
def gato():
    wandomgatos = []
    for gato in glob.glob('gatos/*'):
        wandomgatos.append(gato)
    #wandomgatos = ["gatos/cat.gif","gatos/cat1.gif","gatos/cat2.gif","gatos/cat3.gif","gatos/cat4.jpg","gatos/cat5.jpg","gatos/cat6.jpg","gatos/cat7.jpg","gatos/cat8.jpg","gatos/cat9.jpg","gatos/cat10.jpg","gatos/cat11.jpg","gatos/cat12.jpg","gatos/cat13.jpg","gatos/cat14.jpg","gatos/cat15.jpg","gatos/cat16.jpg","gatos/cat17.jpg","gatos/cat18.jpg"]
    wandomchoice = random.choice(wandomgatos)
    return send_file(wandomchoice,mimetype="imagegif")

app.run(host="0.0.0.0",port=1337)



[/SPOILER]


Thankiesss  :pomhappy:
Arx &lt;3 Punk
Reply


 Users viewing this thread: python flask cat generator api >.<: No users currently viewing.