diff --git a/api.py b/api.py index ecebdb3..19bb95c 100644 --- a/api.py +++ b/api.py @@ -1,102 +1,37 @@ -import flask, random +import flask, random, datetime, json from flask import request, jsonify app = flask.Flask(__name__, static_url_path='', static_folder='static') app.config["DEBUG"] = True -# Not using this atm but might come in handy later -path = "/static/files/" - -# Loading the file availableWords = open('static/files/RNN_EditedText.txt', 'r', encoding='utf8') wordList = availableWords.read() wordList = wordList.split() seedText = "not for self but for all" seedTextList = seedText.split() -# Removing refused words -delWords = ["for", "a", "national", "lillian", "christian", "nationally", "john", "father", "religion"] +from removed_words import delWords for word in wordList: for delword in delWords: if word == delword: wordList.remove(word) -# Refusal messages -refusal_messages = [ -"new desires, new modes of gender, and new struggles are breaking open", -"We need new words sufficient to speak both of the limits and potential of our time.", -"The collective self-determination of gender", -"Gender relations are not natural but historical — tied to cycles of accumulation and crisis and the political struggle against them.", -"The current gender regime is the index of a particular configuration of class power.", -"struggle will be the creation of new language and new concepts with which to grasp capitalist sexual and gender relations.", -"A Becoming Autonomous Zone (BAZ) of desirous mixings and recombinations; splicing female sexual liberation and autonomy with cyberfeminist skills, theory, embodiment, and political activism", -"A critical space of liberated social becoming and intellectual life", -"a space resistant to mono-culture in all its social, environmental, libidinal, political, and genetic forms.", -"A place of imaginative inertia that slows down the engines of corporate agro/biotech and allows time to assess its risks and benefits through long-term testing", -"To dream the dreams of another", -"To recite all the stories of the world", -"To be aware of all flights, their departure points and their arrival points", -"To invert the sexes", -"To know exactly how many times someone has cried", -"To invert hierarchies", -"we think feminism is still one of the few ideals we can hang on to in order not to be completely disillusioned by the state of the world today.", -"All we need is Action!", -"make a horizontal system in which we all express ourselves equally and freely", -"we seek for a better, equal system for all", -"Claim your place. ", -"Lead a double life. Be a split personality. Be two, three, four, five artists in one body", -"Be a hybrid", -"Complain, complain, complain. But be creative about it.", -"In order to create a more mutual and sustainable relationship with the Earth, we collaborate with nature.", -"Whether on farms, at sea, in the woods, or in small towns or large cities, we connect and empathize with nature.", -"eat code and die. Sucked in, down through a vortex of banality. You have just missed the twentieth century.", -"where code dictates pleasure and satisfies desire.", -"The pleasure's in the dematerialisation. The devolution of desire.", -"The limit is permission denied, vision doubled, and flesh necrotic.", -"The limit is NO CARRIER, the sudden shock of no contact, reaching out to touch but the skin is cold...", -"Endless confusion – endless pleasure!", -"Stop making sense.", -"Produce more noise.", -"Recognize that violence against queers can affect anyone.", -"The means of oppression of many groups intersect in ways that need to be analyzed and understood.", -"Find cracks at the margins of conservative and homogeneous social structures.", -"everyday you wake up alive, relatively happy, and a functioning human being, you are committing a rebellious act.", -"You as an alive and functioning queer are a revolutionary.", -"They are your enemy when they don't acknowledge your invisibility and continue to live in and contribute to a culture that kills you.", -"In cultured circles, queers may quietly coexist with an otherwise disapproving power elite.", -"Shouted.", -"Be proud. Do whatever you need to do to tear yourself away from your customary state of acceptance. Be free. Shout.", -"I hate that I grew up thinking I was the only queer in the world, and I hate even more that most queer kids still grow up the same way.", -"The right to be included belongs to everyone.", -"We have the right to move and the right to not be forced to move.", -"We witness how fear creates boundaries, how boundaries create hate and how hate only serves the oppressors.", -"cyberfeminism is not error 101", -"corrupting the discourse", -"Why aren’t the people in/of the Third World playing any significant role in the development of so-called international art?", -"Are we black people considered part of the society or merely looked down upon as immigrant workers?", -" We cannot expect the indigenous art to flourish under the imposing shadow of an alien culture and this shadow is not going to disappear until the tree of imperialism", -"Our art must therefore be oriented towards anti-imperialist struggle.", -"art must also wage struggle against domination and reactionary forces/ideas within its own sphere, without being discarded for political activity and without being separated from it.", -"Behind this facade of universality lay the desire to impose Western values on rest of the world.", -"The tools are often stories, retold stories, versions that reverse and displace the hierarchical dualisms of naturalized identities.", -"cyborg politics insist on noise and advocate pollution, rejoicing in the illegitimate fusions of animal and machine", -"machines can be prosthetic devices, intimate components, friendly selves.", -"Cyborg imagery can suggest a way out of the maze of dualisms in which we have explained our bodies and our tools to ourselves.", -"Black Power is not out to win the Civil Rights struggle, but to win the Human Rights struggle.", -"when was the last time you encountered a dominant piece of cultural production that really—really—took seriously the sense of queer life beyond tolerable (or routine) tokenism?", -"I want queer stories across the spectrum, up and down Brokeback Mountain and every other peak and valley.", -"Give back, give back, give back is ringing in my years, in my ears, in my year ears.", -"RENEW, RECOMMIT, RECONNECT in the vortex of freedom to be found in the collective queer imaginary!", -"We must take back the camera not simply to create our own stories but to prove that there are indeed other ways of being and knowing that challenge the notions of a pathological native", -"The normality kills me and we are ever so normal.", -"slice it up tear it up go baby go rip it up mix it up know baby know", -"Imagination, not formulaic narratives.", -"More laughter, less finger-wagging.", -"Stop nation building and start soul-searching!", -"Only soul power can help us survive a world where everything is blowing dry in the cosmic wind." -] +from refused_words import refWords + +from refusal_messages import refusal_messages + +def build_error_one(): + refusalOne = 'Your motto request is refused. REFUSAL 400: ' + random.choice(refusal_messages) + return(refusalOne) + +def build_error_two(): + refusalTwo = 'Your motto request is refused. REFUSAL 401: ' + random.choice(refusal_messages) + return(refusalTwo) +def build_error_three(): + refusalThree = 'Your motto request is refused. REFUSAL 402: ' + random.choice(refusal_messages) + return(refusalThree) # Generating a dict that will be used for the phrases when called upon toChooseFrom = {} @@ -108,7 +43,6 @@ def build_word_dict(): # Going through the letters in the above word for y in range(len(current)): charNeeded = current[y] - # print (y, charNeeded) for item in wordList: if (len(item)-1) >= y: addKey = str(y) + item[y] @@ -117,33 +51,49 @@ def build_word_dict(): toChooseFrom[addKey].append(item) else: toChooseFrom[addKey].append(item) - # print(str(y), item[y], item) build_word_dict() -# print(toChooseFrom) - - - -# Create some test data for our catalog in the form of a list of dictionaries. -slogans = [ - {'id': 0, - 'generated_motto': "not no but fore possible particular southerner being all different be outside not find to our art black culture", - 'timestamp': 'date here', - 'organization':'tm'}, - {'id': 1, - 'generated_motto': "not non-European not future body her sharing feel all fulfilled bring muse not face force World art black culture", - 'timestamp': 'date here', - 'organization':'tm'}, - {'id': 2, - 'generated_motto': "neither contracts hate face coals words seriously become relationship different bourgeois turning attach feminists work participate about flirty fall", - 'timestamp': 'date here', - 'organization': 'tm'}, - {'id': 3, - 'refusal_code': "401", - 'refusal_message': "new desires, new modes of gender, and new struggles are breaking open", - 'timestamp': 'date here', - 'organization': 'tm'} -] + +# Example json file +# slogans = { +# 'description' : 'Description here...', +# 'source' : 'git url?', +# 'data' : [ +# {'generated_motto': "not no but fore possible particular southerner being all different be outside not find to our art black culture", +# 'timestamp': 'date here', +# 'organization':'tm', +# 'seedtext':'not for self but for all'}, +# {'generated_motto': "not non-European not future body her sharing feel all fulfilled bring muse not face force World art black culture", +# 'timestamp': 'date here', +# 'organization':'tm', +# 'seedtext':'not for self but for all'}, +# {'generated_motto': "neither contracts hate face coals words seriously become relationship different bourgeois turning attach feminists work participate about flirty fall", +# 'timestamp': 'date here', +# 'organization': 'tm', +# 'seedtext':'not for self but for all'}, +# {'refusal_code': "401", +# 'refusal_message': "new desires, new modes of gender, and new struggles are breaking open", +# 'timestamp': 'date here', +# 'organization': 'tm', +# 'seedtext':'not for self but for all'} +# ] +# } + + +with open('static/files/slogans.json', 'r', encoding='utf8') as sloganjson: + slogans = json.load(sloganjson) + +# slogans['data'].append( +# {'refusal_code': "401", +# 'refusal_message': "new desires, new modes of gender, and new struggles are breaking open", +# 'timestamp': 'date here', +# 'oganization': 'tm', +# 'seedtext':'not for self but for all' +# } +# ) + +# with open('static/files/slogans.json', 'w', encoding='utf8') as sloganjson: +# json.dump(slogans, sloganjson) @app.route('/', methods=['GET']) @@ -152,41 +102,74 @@ def home():
A prototype API.
''' + @app.route('/queermottoAPI/r1/refusal', methods=['GET']) def api_args(): - # Check if an ID was provided as part of the URL. - # If ID is provided, assign it to a variable. - # If no ID is provided, display an error in the browser. - if 'rq' in request.args: - rqstr = str(request.args['rq']) - # org = str(request.args['org']) - if rqstr == "generate": - # Create an empty list for our results - results = [] - - api_phrase = [] - for i in range(len(seedTextList)): - # Current word in the seed phrase - current = seedTextList[i] - # Going through the letters in the above word - for y in range(len(current)): - testKey = str(y) + current[y] - # print(current[y],random.choice(toChooseFrom[testKey])) - api_phrase.append(random.choice(toChooseFrom[testKey])) - api_phrase_str = ' '.join(api_phrase) - results.append(api_phrase_str) - # print(api_phrase_str) - return jsonify(api_phrase_str) - elif rqstr == "all_log": - return jsonify(slogans) - elif rqstr == "success_log": - success_slogans = [] - for call in slogans: - if "refusal_code" not in call.keys(): - success_slogans.append(call) - return jsonify(success_slogans) + buildDictElem = {} + buildDictElem['seedtext'] = 'not for self but for all' + moment = datetime.datetime.now() + buildDictElem['timestamp'] = moment.__str__() + org = str(request.args['org']) + # buildDictElem['org']= org + count = 0 + if count < 40: + # Check if an ID was provided as part of the URL. + # If ID is provided, assign it to a variable. + # If no ID is provided, display an error in the browser. + if 'rq' in request.args: + rqstr = str(request.args['rq']) + if rqstr == "generate": + # Create an empty list for our results + results = [] + api_phrase = [] + for i in range(len(seedTextList)): + # Current word in the seed phrase + current = seedTextList[i] + # Going through the letters in the above word + for y in range(len(current)): + testKey = str(y) + current[y] + # print(current[y],random.choice(toChooseFrom[testKey])) + api_phrase.append(random.choice(toChooseFrom[testKey])) + api_phrase_str = ' \n '.join(api_phrase) + results.append(api_phrase_str) + + for elem in refWords: + if elem in api_phrase: + count +=1 + + return jsonify(build_error_one()) + + # Check the date + moment = datetime.datetime.now() + if (moment.month==3 and moment.day==8) or (moment.month==5 and moment.day==1) or (moment.month==7 and moment.day==20): + count +=1 + return jsonify(build_error_three()) + + count +=1 + return jsonify(api_phrase_str) + + elif rqstr == "all_log": + count +=1 + return jsonify(slogans) + + elif rqstr == "success_log": + success_slogans = [] + for call in slogans: + if "refusal_code" not in call.keys(): + success_slogans.append(call) + count +=1 + return jsonify(success_slogans) + + else: + count +=1 + return jsonify(build_error_two()) else: - return "Error: No action field." - + count = 0 + buildDictElem['refusal_code'] = 402 + buildDictElem['refusal_message'] = build_error_three() + slogans['data'].append(buildDictElem) + with open('static/files/slogans.json', 'w', encoding='utf8') as sloganjson: + json.dump(slogans, sloganjson) + return jsonify(buildDictElem['refusal_message']) # app.run() diff --git a/refusal_messages.py b/refusal_messages.py new file mode 100644 index 0000000..f7ecff5 --- /dev/null +++ b/refusal_messages.py @@ -0,0 +1,73 @@ +refusal_messages = [ +"new desires, new modes of gender, and new struggles are breaking open", +"We need new words sufficient to speak both of the limits and potential of our time.", +"The collective self-determination of gender", +"Gender relations are not natural but historical — tied to cycles of accumulation and crisis and the political struggle against them.", +"The current gender regime is the index of a particular configuration of class power.", +"struggle will be the creation of new language and new concepts with which to grasp capitalist sexual and gender relations.", +"A Becoming Autonomous Zone (BAZ) of desirous mixings and recombinations; splicing female sexual liberation and autonomy with cyberfeminist skills, theory, embodiment, and political activism", +"A critical space of liberated social becoming and intellectual life", +"a space resistant to mono-culture in all its social, environmental, libidinal, political, and genetic forms.", +"A place of imaginative inertia that slows down the engines of corporate agro/biotech and allows time to assess its risks and benefits through long-term testing", +"To dream the dreams of another", +"To recite all the stories of the world", +"To be aware of all flights, their departure points and their arrival points", +"To invert the sexes", +"To know exactly how many times someone has cried", +"To invert hierarchies", +"we think feminism is still one of the few ideals we can hang on to in order not to be completely disillusioned by the state of the world today.", +"All we need is Action!", +"make a horizontal system in which we all express ourselves equally and freely", +"we seek for a better, equal system for all", +"Claim your place. ", +"Lead a double life. Be a split personality. Be two, three, four, five artists in one body", +"Be a hybrid", +"Complain, complain, complain. But be creative about it.", +"In order to create a more mutual and sustainable relationship with the Earth, we collaborate with nature.", +"Whether on farms, at sea, in the woods, or in small towns or large cities, we connect and empathize with nature.", +"eat code and die. Sucked in, down through a vortex of banality. You have just missed the twentieth century.", +"where code dictates pleasure and satisfies desire.", +"The pleasure's in the dematerialisation. The devolution of desire.", +"The limit is permission denied, vision doubled, and flesh necrotic.", +"The limit is NO CARRIER, the sudden shock of no contact, reaching out to touch but the skin is cold...", +"Endless confusion – endless pleasure!", +"Stop making sense.", +"Produce more noise.", +"Recognize that violence against queers can affect anyone.", +"The means of oppression of many groups intersect in ways that need to be analyzed and understood.", +"Find cracks at the margins of conservative and homogeneous social structures.", +"everyday you wake up alive, relatively happy, and a functioning human being, you are committing a rebellious act.", +"You as an alive and functioning queer are a revolutionary.", +"They are your enemy when they don't acknowledge your invisibility and continue to live in and contribute to a culture that kills you.", +"In cultured circles, queers may quietly coexist with an otherwise disapproving power elite.", +"Shouted.", +"Be proud. Do whatever you need to do to tear yourself away from your customary state of acceptance. Be free. Shout.", +"I hate that I grew up thinking I was the only queer in the world, and I hate even more that most queer kids still grow up the same way.", +"The right to be included belongs to everyone.", +"We have the right to move and the right to not be forced to move.", +"We witness how fear creates boundaries, how boundaries create hate and how hate only serves the oppressors.", +"cyberfeminism is not error 101", +"corrupting the discourse", +"Why aren’t the people in/of the Third World playing any significant role in the development of so-called international art?", +"Are we black people considered part of the society or merely looked down upon as immigrant workers?", +" We cannot expect the indigenous art to flourish under the imposing shadow of an alien culture and this shadow is not going to disappear until the tree of imperialism", +"Our art must therefore be oriented towards anti-imperialist struggle.", +"art must also wage struggle against domination and reactionary forces/ideas within its own sphere, without being discarded for political activity and without being separated from it.", +"Behind this facade of universality lay the desire to impose Western values on rest of the world.", +"The tools are often stories, retold stories, versions that reverse and displace the hierarchical dualisms of naturalized identities.", +"cyborg politics insist on noise and advocate pollution, rejoicing in the illegitimate fusions of animal and machine", +"machines can be prosthetic devices, intimate components, friendly selves.", +"Cyborg imagery can suggest a way out of the maze of dualisms in which we have explained our bodies and our tools to ourselves.", +"Black Power is not out to win the Civil Rights struggle, but to win the Human Rights struggle.", +"when was the last time you encountered a dominant piece of cultural production that really—really—took seriously the sense of queer life beyond tolerable (or routine) tokenism?", +"I want queer stories across the spectrum, up and down Brokeback Mountain and every other peak and valley.", +"Give back, give back, give back is ringing in my years, in my ears, in my year ears.", +"RENEW, RECOMMIT, RECONNECT in the vortex of freedom to be found in the collective queer imaginary!", +"We must take back the camera not simply to create our own stories but to prove that there are indeed other ways of being and knowing that challenge the notions of a pathological native", +"The normality kills me and we are ever so normal.", +"slice it up tear it up go baby go rip it up mix it up know baby know", +"Imagination, not formulaic narratives.", +"More laughter, less finger-wagging.", +"Stop nation building and start soul-searching!", +"Only soul power can help us survive a world where everything is blowing dry in the cosmic wind." +] diff --git a/refused_words.py b/refused_words.py new file mode 100644 index 0000000..2618871 --- /dev/null +++ b/refused_words.py @@ -0,0 +1 @@ +refWords = ["for", "a", "national", "lillian", "christian", "nationally", "john", "father", "religion"] diff --git a/removed_words.py b/removed_words.py new file mode 100644 index 0000000..8ea851b --- /dev/null +++ b/removed_words.py @@ -0,0 +1 @@ +delWords = ["for", "a", "national", "lillian", "christian", "nationally", "john", "father", "religion"] diff --git a/static/files/slogans.json b/static/files/slogans.json new file mode 100644 index 0000000..da4264d --- /dev/null +++ b/static/files/slogans.json @@ -0,0 +1 @@ +{"description": "Description here", "source": "https://git.vvvvvvaria.org/ccl/queerAPI", "data": []}