Trying out GitHub gists by printing hello worlds.
There are different ways of sending data via http, a common option is to use html forms.
<form method="POST">
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br>
<label for="age">Age:</label><br>
<input type="text" id="age" name="age">
</form>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# use the app.route with syntactic sugar | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/<string:name>') | |
def hello(name): | |
return f"Hello {name}" | |
if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const R = require("rambda"); | |
// Get the nth fibonacci number | |
const nthFib = R.cond([ | |
[R.equals(1), R.always(1)], | |
[R.equals(2), R.always(1)], | |
[R.T, n => nthFib(n-1) + nthFib(n-2)] | |
]); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
int x = 5; // Value x | |
int* xPtr= &x; // A pointer to x | |
*xPtr = 6; // Change value via indirection operator | |
printf("The value of x is: %d\n", x); // x = 6 | |
return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import time | |
# Hello world async/await | |
async def hello(): | |
print("Hello") | |
await asynio.sleep(2) | |
print("World!") | |
asyncio.run(hello()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def infCount(): | |
""" | |
Infinite counter | |
""" | |
i = 0 | |
while True: | |
yield i | |
i += 1 | |
# Usage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* infCount(){ | |
let i = 0 | |
while (true){ | |
yield i | |
i += 1 | |
} | |
} | |
let inf = infCount() | |
inf.next() // { value: 0, done: false } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
struct point{ | |
int x; | |
int y; | |
}; | |
struct point p1 = {10, 20}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef struct point{ | |
int x; | |
int y; | |
} Point; | |
typedef int length; | |
int main(){ |
OlderNewer