Flask app that interacts with the Waifu API to fetch and display tags and search for images based on parameters you provided. 🚀
### Flask App Structure
1. Install Flask: Make sure you have Flask installed. You can do this via pip:
2. Create your Flask app: Below is the complete code for the Flask app:
3. Create Template File:
Create a folder named
How to Run the App
1. Save the Python script (e.g.,
2. Run the Flask app:
3. Open your web browser and go to
### Flask App Structure
1. Install Flask: Make sure you have Flask installed. You can do this via pip:
pip install Flask
2. Create your Flask app: Below is the complete code for the Flask app:
from flask import Flask, jsonify, render_template
import requests
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/tags')
def get_tags():
url = 'https://api.waifu.im/tags'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
return jsonify(data)
else:
return jsonify({'error': 'Request failed with status code:', 'status': response.status_code}), response.status_code
@app.route('/search/<tag>')
def search_images(tag):
url = 'https://api.waifu.im/search'
params = {
'included_tags': [tag],
}
response = requests.get(url, params=params)
if response.status_code == 200:
data = response.json()
return jsonify(data)
else:
return jsonify({'error': 'Request failed with status code:', 'status': response.status_code}), response.status_code
if __name__ == '__main__':
app.run(debug=True)
3. Create Template File:
Create a folder named
templates in the same directory as your Flask app and create a file named index.html.<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Waifu App</title>
</head>
<body>
<h1>Welcome to the Waifu App! 🌟</h1>
<h2>Available Tags and Image Search</h2>
<p>Use the following endpoints:</p>
<ul>
<li><a href="/tags">Get Tags</a></li>
<li>Search Images: <a href="/search/maid">Maid Images</a></li>
</ul>
</body>
</html>
How to Run the App
1. Save the Python script (e.g.,
app.py) and the HTML file.2. Run the Flask app:
python app.py
3. Open your web browser and go to
http://127.0.0.1:5000/ to see the app in action! 🎉❤5👍4
Jinke pass bhi Groups hain 10 members se 250 members tak ke vo mujhe de sakte hain
(Only telegram groups no newly created)
And don't comment here directly message me
Minimum Price 50 rupye maximum price can be 100 vary based on group
And in special group case it will be more
@Panditsiddharth
Or Call 6389680622
(Only telegram groups no newly created)
And don't comment here directly message me
Minimum Price 50 rupye maximum price can be 100 vary based on group
And in special group case it will be more
@Panditsiddharth
Or Call 6389680622
👍3
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
How can you select a specific column from a DataFrame?
Anonymous Quiz
25%
df.select_column("ColumnName")
30%
df.get_column("ColumnName")
35%
df["ColumnName"]
10%
df.column("ColumnName")
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
How can you filter rows in a DataFrame based on a condition?
Anonymous Quiz
26%
df.filter(condition)
25%
df[condition]
22%
df.select_rows(condition)
27%
df.filter_rows(condition)
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
How can you drop a column from a DataFrame in Pandas?
Anonymous Quiz
16%
df.remove_column("ColumnName")
36%
df.drop_column("ColumnName")
27%
df.remove("ColumnName", axis=1)
21%
df.drop("ColumnName", axis=1)
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
What does the groupby() function in Pandas allow you to do?
Anonymous Quiz
15%
Group DataFrame columns
41%
Group DataFrame rows based on a condition
30%
Group data based on one or more columns
15%
Group data based on the index
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
How can you merge two DataFrames in Pandas?
Anonymous Quiz
25%
df.concat()
20%
df.join()
46%
df.merge()
9%
df.combine()
👍3❤1
We have started new Channel.
Is channels me aapko 8000 se lekar 1lack+ salary ke jobs achive karne ke liye kya skills required hoti hain unke bare me batayenge.
Kya kya jaroori hota hai cv, experience, education and knowledge se lekar bahut kuchh
Har ek field jaise accounting, Software development se lekar Har tarah ke work ki skills.
To wait karne ki bajay join karlo👇
@NaukriSkills
Is channels me aapko 8000 se lekar 1lack+ salary ke jobs achive karne ke liye kya skills required hoti hain unke bare me batayenge.
Kya kya jaroori hota hai cv, experience, education and knowledge se lekar bahut kuchh
Har ek field jaise accounting, Software development se lekar Har tarah ke work ki skills.
To wait karne ki bajay join karlo👇
@NaukriSkills
❤1
Hollow Rectangle Pattern in python
Output:
def hollow_rectangle_pattern(Totalrow,TotalCol):
for i in range(1, Totalrow+1):
for j in range(1,TotalCol+1):
if (i==1 or j==1 or i==Totalrow or j==TotalCol):
print("*",end="")
else:
print(" ",end="")
print("")
hollow_rectangle_pattern(4,7)
Output:
*******
* *
* *
*******
👍2
Inverted Half Rotated Pyramid
Output:
def inverted_half_pyramid(n):
for i in range(0, n+1):
for j in range(0, n-i):
print(" ",end="")
for j in range(0, i):
print("*",end="")
print()
inverted_half_pyramid(6)
Output:
*
**
***
****
*****
******
❤1
Inverted rotated Pyramid of number
Output;
def invert_half_pyra(n: int):
for i in range(0, n):
for j in range(1, n - i + 1):
print(j, end="")
print()
invert_half_pyra(n=5)
Output;
12345
1234
123
12
1
❤1👏1
Floyd`s Triangle Pattern.
OutPut:
def floyd_triangle(n):
count=1
for i in range(0, n+1):
for j in range(0, i):
print(count,end=" ")
count+=1
print()
floyd_triangle(5)
OutPut:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
❤2
0-1 Triangle Pattern
Output:
def zero_one_triangle(num):
"""
Purpose: for triangle pattern
"""
for i in range(1,num+1):
for j in range(1,i+1):
# print(i+j)
if ((i+j)%2)==0:
print("1",end=" ")
else:
print("0",end=" ")
print()
zero_one_triangle(5)
Output:
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
❤3
Reverse an array
Output:
import numpy as np
def Reversed(numbers:np.array):
# Reverse an array
start = 0
last = len(numbers)-1
while (start < last):
temp = numbers[last]
numbers[last] = numbers[start]
numbers[start] = temp
start+=1
last-=1
numbers=np.array([2,4,6,8,10,12,14,16])
Reversed(numbers)
for item in range(0,len(numbers)):
print(numbers[item],end=" ")
# time complexbilty: 0(n)
# space complexbilty: 0(1)
Output:
16 14 12 10 8 6 4 2
❤7
String functions
https://t.me/Python_Codes_Pro/86
20 Questions on python loops:
https://t.me/Python_Codes_Pro/135
https://t.me/Python_Codes_Pro/86
20 Questions on python loops:
https://t.me/Python_Codes_Pro/135
Telegram
Python Codes Basic to Advance
String functions
1. len(str): Returns the length of the string.
2. str.lower(): Returns a copy of the string in lowercase.
3. str.upper(): Returns a copy of the string in uppercase.
4. str.capitalize(): Returns a copy of the string with the first character…
1. len(str): Returns the length of the string.
2. str.lower(): Returns a copy of the string in lowercase.
3. str.upper(): Returns a copy of the string in uppercase.
4. str.capitalize(): Returns a copy of the string with the first character…
❤2
Join Coding
https://t.me/addlist/2UhsQW_cGzkxMzg1
https://t.me/addlist/2UhsQW_cGzkxMzg1
Random User API
SAMPLE OUTPUT :
import requests
response = requests.get('https://randomuser.me/api/')
if response.status_code == 200:
data = response.json()
print(data)
else:
print(f"Request failed with status code: {response.status_code}")
SAMPLE OUTPUT :
{'results': [{'gender': 'male', 'name': {'title': 'Mr', 'first': 'Milan', 'last': 'Abramović'}, 'location': {'street': {'number': 2467, 'name': 'Kosmajska'}, 'city': 'Velika Plana', 'state': 'Pirot', 'country': 'Serbia', 'postcode': 56590, 'coordinates': {'latitude': '59.7052', 'longitude': '-4.6310'}, 'timezone': {'offset': '+2:00', 'description': 'Kaliningrad, South Africa'}}, 'email': 'milan.abramovic@example.com', 'login': {'uuid': '70836e88-df56-4d84-9ffb-019ce46966f0', 'username': 'yellowpanda148', 'password': 'walton', 'salt': 'Z7tx2Gqu', 'md5': '9eef7a132080107f50ea08cbe15172a7', 'sha1': '5eff350899a05ded6d669dbd866db110cc15c408', 'sha256': '334aa1d791d2b4170edaf6b7d14fb9b5ef319edea4c680dab50ea42c8caa22d4'}, 'dob': {'date': '1949-12-26T22:18:46.892Z', 'age': 75}, 'registered': {'date': '2014-05-18T23:17:21.440Z', 'age': 11}, 'phone': '032-3543-907', 'cell': '061-1365-392', 'id': {'name': 'SID', 'value': '235500700'}, 'picture': {'large': 'https://randomuser.me/api/portraits/men/78.jpg', 'medium': 'https://randomuser.me/api/portraits/med/men/78.jpg', 'thumbnail': 'https://randomuser.me/api/portraits/thumb/men/78.jpg'}, 'nat': 'RS'}], 'info': {'seed': 'dff3fde1e00d2302', 'results': 1, 'page': 1, 'version': '1.4'}}❤3
Forwarded from Cᴏᴅᴇs Sɴɪᴘᴘᴇᴛs (</> ᴍᴜᴋᴇsʜ </>)
Count Printable character from file using Python
Sample Output:
from string import printable
def count_char():
with open(r"bookbot/books/frankenstein.txt", "r", encoding="utf-8") as f:
file_contents = f.read().lower()
char=list(printable)
d=dict()
for i in char:
d[i]=0
for i in file_contents:
if i in d:
d[i]+=1
print(d)
count_char()
Sample Output:
{'0': 18, '1': 91, '2': 19, '3': 15, '4': 12, '5': 12, '6': 9, '7': 18, '8': 24, '9': 9, 'a': 25894, 'b': 4868, 'c': 9011, 'd': 16318, 'e': 44538, 'f': 8451, 'g': 5795, 'h': 19176, 'i': 23927, 'j': 497, 'k': 1661, 'l': 12306, 'm': 10206, 'n': 23643, 'o': 24494, 'p': 5952, 'q': 325, 'r': 20079, 's': 20360, 't': 29493, 'u': 10111, 'v': 3737, 'w': 7450, 'x': 691, 'y': 7756, 'z': 235, 'A': 0, 'B': 0, 'C': 0, 'D': 0, 'E': 0, 'F': 0, 'G': 0, 'H': 0, 'I': 0, 'J': 0, 'K': 0, 'L': 0, 'M': 0, 'N': 0, 'O': 0, 'P': 0, 'Q': 0, 'R': 0, 'S': 0, 'T': 0, 'U': 0, 'V': 0, 'W': 0, 'X': 0, 'Y': 0, 'Z': 0, '!': 201, '"': 0, '#': 1, '$': 2, '%': 1, '&': 5, "'": 0, '(': 35, ')': 35, '*': 97, '+': 0, ',': 5962, '-': 173, '.': 3121, '/': 8, ':': 211, ';': 1350, '<': 0, '=': 0, '>': 0, '?': 208, '@': 0, '[': 2, '\\': 0, ']': 2, '^': 0, '_': 124, '`': 0, '{': 0, '|': 0, '}': 0, '~': 0, ' ': 70480, '\t': 0, '\n': 7631, '\r': 0, '\x0b': 0, '\x0c': 0}❤5
Join BCA/MCA developers group on arattai
A Indian chat app by zoho Supported by government
https://chat.arattai.in/groups/t43545f313237373536333834333438343434363931355f32303030353533333235382d47437c3031303131353032353136343137353935303935383035393830
A Indian chat app by zoho Supported by government
https://chat.arattai.in/groups/t43545f313237373536333834333438343434363931355f32303030353533333235382d47437c3031303131353032353136343137353935303935383035393830
chat.arattai.in
BCA MCA ( Developers )
❤1