ccl
4 years ago
2 changed files with 198 additions and 0 deletions
@ -0,0 +1,197 @@ |
|||||
|
import flask, random |
||||
|
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"] |
||||
|
|
||||
|
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." |
||||
|
] |
||||
|
|
||||
|
|
||||
|
# Generating a dict that will be used for the phrases when called upon |
||||
|
toChooseFrom = {} |
||||
|
|
||||
|
def build_word_dict(): |
||||
|
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)): |
||||
|
charNeeded = current[y] |
||||
|
# print (y, charNeeded) |
||||
|
for item in wordList: |
||||
|
if (len(item)-1) >= y: |
||||
|
addKey = str(y) + item[y] |
||||
|
if addKey not in toChooseFrom.keys(): |
||||
|
toChooseFrom[addKey] = [] |
||||
|
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'} |
||||
|
] |
||||
|
|
||||
|
|
||||
|
@app.route('/', methods=['GET']) |
||||
|
def home(): |
||||
|
return '''<h1>Queer API</h1> |
||||
|
<p>A prototype API.</p>''' |
||||
|
|
||||
|
|
||||
|
@app.route('/queerAPI/refusal/all', methods=['GET']) |
||||
|
def api_all(): |
||||
|
return jsonify(slogans) |
||||
|
|
||||
|
|
||||
|
@app.route('/queerAPI/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) |
||||
|
else: |
||||
|
return "Error: No action field." |
||||
|
|
||||
|
|
||||
|
# app.run() |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue