diff --git a/api/api.md b/api/api.md new file mode 100644 index 0000000..7afb4df --- /dev/null +++ b/api/api.md @@ -0,0 +1,12 @@ +# API in python + +Required python packages +- fastapi +- uvicorn +- flask + +Install with pip3 install + + +## Sources +- https://youtu.be/zsYIw6RXjfM \ No newline at end of file diff --git a/api/main.py b/api/main.py new file mode 100644 index 0000000..9d70a86 --- /dev/null +++ b/api/main.py @@ -0,0 +1,16 @@ +from flask import Flask, request, jsonify, redirect + +app = Flask(__name__) + +@app.route("/hello") +def helloWorld(): + return "Hello World" + +@app.route("/") +def shortUrl(slug): + #return f"This is a short url! Your slug: {slug}" + destination = f"https://www.google.com/search?q={slug}" + return redirect(destination, code=302) + +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file