Verified Commit b7b14e76 authored by frju365's avatar frju365

Initial commit

parents
__pycache__
.idea
\ No newline at end of file
from generate_game import Game
@app.route('/api')
def api_accueil():
return ''
\ No newline at end of file
from flask import Flask
app = Flask(__name__)
import api.py
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
import simplejson as json
import psycopg2
from config import config
def generate_rand_number(y):
return random.randint(Game.x, y)
\ No newline at end of file
import json
import random
from functions import generate_rand_number
class Game:
"""Class which will generate each game at API call"""
x = 0
@staticmethod
def generate_game():
with open("json_captcha/game_type1.json", "r") as fichier:
json_decoded = json.load(fichier)
len_dict = len(json_decoded) - 1
rand_number = generate_rand_number(len_dict)
return json_decoded[rand_number]
{
"1": {
"title": "025468798654",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
},
"2": {
"title": "025468798656",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
},
"3": {
"title": "025468798650",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
},
"4": {
"title": "025468798654",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
},
"5": {
"title": "025468798654",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
},
"6": {
"title": "025468798654",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
},
"7": {
"title": "025468798654",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
},
"8": {
"title": "025468798654",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
},
"9": {
"title": "025468798654",
"question": "Trouvez l'adresse du post correspondant à l'image ci-dessus.",
"image": "mastodon.025468798654.png"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment