Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f49eaac964 | ||
|
|
48920ae54a | ||
|
|
4e3e08f11d | ||
|
|
8377835f36 |
@@ -14,8 +14,7 @@ git clone https://github.com/DarkShyMW/Random-batpony-generator.git
|
|||||||
От туда копируем ваш api_key. Его вставляем в 8 строку - api_key = "тут_ваш_ключ"
|
От туда копируем ваш api_key. Его вставляем в 8 строку - api_key = "тут_ваш_ключ"
|
||||||
|
|
||||||
```
|
```
|
||||||
pip3 install Flask
|
pip install flask requests flask_bootstrap
|
||||||
pip3 install requests
|
|
||||||
|
|
||||||
cd /путь_до_папки/
|
cd /путь_до_папки/
|
||||||
python3 pony.git
|
python3 pony.git
|
||||||
|
|||||||
9
pony.py
9
pony.py
@@ -1,15 +1,20 @@
|
|||||||
import requests
|
import requests
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
import random
|
import random
|
||||||
|
from flask_bootstrap import Bootstrap
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
Bootstrap(app)
|
||||||
|
|
||||||
|
|
||||||
# Пишем свой API-key из https://derpibooru.org/registrations/edit
|
# Пишем свой API-key из https://derpibooru.org/registrations/edit
|
||||||
api_key = "ваш_код"
|
api_key = "ваш_токен"
|
||||||
|
querry = 'batpony,safe,cute'
|
||||||
|
|
||||||
# Ищем картинки на derpi
|
# Ищем картинки на derpi
|
||||||
def get_random_batpony_image():
|
def get_random_batpony_image():
|
||||||
url = f"https://derpibooru.org/api/v1/json/search?q=batpony%2Csafe&key={api_key}"
|
url = f"https://derpibooru.org/api/v1/json/search?q={querry}%2Csafe&key={api_key}"
|
||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,53 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ru">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Рандом бетпони поисковик</title>
|
<title>Batpony Image</title>
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
|
||||||
<style>
|
<style>
|
||||||
.container {
|
body {
|
||||||
max-width: 600px;
|
display: flex;
|
||||||
max-height: 400px;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
min-height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
.batpony-image {
|
header {
|
||||||
width: 30%;
|
text-align: center;
|
||||||
height: 30%;
|
color: #eed70a;
|
||||||
|
background-color: #5d6469;
|
||||||
|
padding-left: 5px;
|
||||||
|
padding-right: 5px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
text-align: center;
|
||||||
|
color: #eed70a;
|
||||||
|
padding: 1rem 0;
|
||||||
|
background-color: #5d6469;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
color:red;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Рандом бетпони поисковик</h1>
|
<header><h1>Random Pony Generator by Dark<span>Shy</span></h1></header>
|
||||||
<content class="container">
|
<main>
|
||||||
<img class="batpony-image" src="{{ image_url }}" alt="Random Batpony Image">
|
<div class="container">
|
||||||
<p>Источник: <a href="{{ view_url }}" target="_blank">{{ view_url }}</a></p>
|
<div class="text-center">
|
||||||
<p>Теги: {{ tags }}</p>
|
<img src="{{ image_url }}" alt="Batpony Image" class="img-fluid">
|
||||||
</content>
|
</div>
|
||||||
<footer>
|
<div class="text-center">
|
||||||
<h3>Весь контент является публичным и случайно найденным для каждого пользователя. <br /> Администрация сайта не несет ответственности за картинки.</h3>
|
<p>Tags: {{ tags }}</p>
|
||||||
</footer>
|
<a href="{{ view_url }}" target="_blank" class="btn btn-primary">Посмотреть на Derpibooru</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<footer><h3>Все права принадлежат поням.</h3> <br> <a href="https://github.com/DarkShyMW/Random-batpony-generator"><span>Исходный код</span></a></footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user