async def index(request, path=""): user_message = request.args.get('message') print(user_message) if user_message: ans = cow.Cowacter().milk(user_message) else: ans = cow.Cowacter().milk(path) if request.args.get('format') == 'json': response = json({'cow': ans}) else: response = text(ans) return (response)
def catch_all(path): user_message = request.args.get('message', type = str) print(user_message) if user_message: ans = cow.Cowacter().milk(user_message) else: ans = cow.Cowacter().milk(path) response = app.response_class( response=json.dumps(ans), status=200, mimetype='application/json' ) return response
def do_GET(self): self.send_response(200) self.send_header('Content-type','text/plain') self.end_headers() message = cow.Cowacter().milk('Hello from Python from a Serverless Function!') self.wfile.write(message.encode()) return
def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/plain') self.end_headers() message = cow.Cowacter().milk('pip:RANDOMNESS_PLACEHOLDER') self.wfile.write(message.encode()) return
def do_GET(self): self.send_response(200) self.send_header('Content-type','text/plain') self.end_headers() message = cow.Cowacter().milk('Hello you are beautiful today!') self.wfile.write(message.encode()) return
def do_GET(self): self.send_response(200) self.send_header('Content-type','text/plain') self.end_headers() message = cow.Cowacter().milk('Hello from Python on Now Lambda!1111111') self.wfile.write(message.encode()) return
def main(req: func.HttpRequest) -> func.HttpResponse: logging.info('Python HTTP trigger function processed a request.') msg = cow.Cowacter(eyes=random.choice(list(cow.eye_options()))).milk( get_message(req)) return func.HttpResponse(msg, status_code=200)
def do_GET(self): self.send_response(200) self.send_header("Content-Type", "text/plain") self.end_headers() message = cow.Cowacter().milk( "Hello from Python from a ZEIT Now Serverless function") self.wfile.write(message.encode()) return
def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/plain') self.end_headers() parsed = urlparse(self.path) urlPath = parsed.path message = cow.Cowacter().milk('Get from: ' + str(urlPath)) self.wfile.write(message.encode()) return
def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/plain') self.end_headers() first = path.exists('ignoreme/first.txt') second = path.exists('ignoreme/second.txt') message = cow.Cowacter().milk(('%s:%s:RANDOMNESS_PLACEHOLDER') % (first, second)) self.wfile.write(message.encode()) return
def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/plain') self.end_headers() print(parse_qs(self.path[2:])) parsed_params = parse_qs(self.path[2:]) message = cow.Cowacter().milk( 'Hello from Python Vercel - {parsed_params}!'.format(parsed_params=parsed_params)) self.wfile.write(message.encode()) return
async def cowsay(self, ctx, *, message): moo = cow.Cowacter(thoughts=True) msg = moo.milk(msg=message) embed = discord.Embed( color=self.bot.embed_color, title="→ Cowsay 🐮", description= f"Moo! ```{msg} ```") await ctx.send(embed=embed) logger.info(f"Fun | Sent Cowsay: {ctx.author}")
def do_GET(self): self.send_response(200) self.send_header('Content-type', 'text/plain') self.end_headers() print(os.getcwd()) from os import listdir from os.path import isfile, join onlyfiles = [ f for f in listdir(os.getcwd()) if isfile(join(os.getcwd(), f)) ] print(onlyfiles) with open('./_files/file.txt', 'r') as fptr: data = fptr.read() message = cow.Cowacter().milk( 'Hello, here is the file contents: {data}'.format(data=data)) self.wfile.write(message.encode()) return
def do_GET(self): productions = { 'tech': [ 'HTML5', 'WebAssembly', 'CoffeeScript', 'pug', 'jQuery', 'Assembly', 'Mashups', 'puppeteer', 'Bootstrap', 'jango', 'CSS', 'git', 'Java', 'Bash', 'Monads', 'AI', 'R', 'Rust' ], 'other': [ 'facial recognition', 'coffee', 'Blockhain', 'vim', 'facebook', 'minecraft', 'code network' ], 'person': ['river city labs', 'cats', 'code network', 'peter laurie'], # pp = preposition phrase 'pp': [ 'in 140 characters', 'in small pieces', 'on a Raspberry Pi', 'in two days', 'FTW' ], 'talk': [ '${tech} for ${person}', '${tech} + ${tech} = awesome', '${tech} with ${other}', '${tech} and ${other}', '${tech} ${pp}', 'How to use ${tech} to make an amazing mess', ] } def randomly_generated(nt): template = random.choice(productions[nt]) def replace(match): return randomly_generated(match.group(1)) return re.sub(r'\$\{(\w+)\}', replace, template) self.send_response(200) self.send_header('Content-type', 'text/plain') self.end_headers() message = cow.Cowacter().milk(randomly_generated('talk')) self.wfile.write(message.encode()) return
def do_GET(self): parsed_path = urlparse.urlparse(self.path) # message_parts = [ # 'CLIENT VALUES:', # 'client_address=%s (%s)' % (self.client_address, # self.address_string()), # 'command=%s' % self.command, # 'path=%s' % self.path, # 'real path=%s' % parsed_path.path, # 'query=%s' % parsed_path.query, # 'params=%s' % parsed_path.params, # 'request_version=%s' % self.request_version, # '', # 'SERVER VALUES:', # 'server_version=%s' % self.server_version, # 'sys_version=%s' % self.sys_version, # 'protocol_version=%s' % self.protocol_version, # '', # 'HEADERS RECEIVED:', # ] # for name, value in sorted(self.headers.items()): # message_parts.append('%s=%s' % (name, value.rstrip())) # message_parts.append('') # message = '\r\n'.join(message_parts) self.send_response(200) self.send_header("Access-Control-Allow-Origin", "*") self.end_headers() query = urlparse.parse_qs(parsed_path.query) print(query) message = 'Mooooooo....' if "message" in query: message = str(query['message'][0]) print(message) message = cow.Cowacter().milk(message) self.wfile.write(message.encode('utf8')) return
",": "--..--", ":": "---...", "?": "..--..", "'": ".----.", "-": "-....-", "/": "-..-.", "@": ".--.-.", "=": "-...-", " ": "/" } decode_morse = dict( (morse_char, char) for (char, morse_char) in encode_morse.items()) cowList = { "cow": cow.Cowacter(), "hellokitty": cow.HelloKitty(), "bunny": cow.Bunny(), "cheese": cow.Cheese(), "milk": cow.Milk(), "bong": cow.BongCow(), "eyes": cow.Eyes(), "legitvore": cow.HeadInCow(), "666": cow.Satanic(), "frogs": cow.BudFrogs(), "daemon": cow.Daemon(), "moofasa": cow.Moofasa(), "mutilated": cow.Mutilated(), "skeleton": cow.Skeleton(), "small": cow.Small(), "sodomized": cow.Sodomized(),
@app.route("/", methods=['GET', 'POST']) def hello(): if request.method == 'POST': if request.form['token'] != slack_token: return "Look what you made me do :)!" txt = request.form['text'] if len(txt) == 0: txt = 'list' if txt in cast_cmds: run_cmd(txt, []) if txt.split(" ")[0] in cast_cmds: return run_cmd(txt.split(" ")[0], txt.split(" ")[1:]) return "unknown command" else: return "Hello World!" cowsay = cow.Cowacter().milk @app.route("/cowsay", methods=['POST']) def _cowsay(): if request.form['token'] != slack_token_cowsay: return ':(' txt = request.form['text'] if len(txt) == 0: return 'Usage: /cowsay [some text]' return cowsay(txt)
def apm_endpoint(): message = cow.Cowacter().milk('Hello from Python from Getting APM Started') print(message) return message