create simple api & take some notes

This commit is contained in:
michivonah 2023-08-27 16:43:59 +02:00
parent 43564dc7c8
commit 48b7dcd892
2 changed files with 28 additions and 0 deletions

12
api/api.md Normal file
View file

@ -0,0 +1,12 @@
# API in python
Required python packages
- fastapi
- uvicorn
- flask
Install with pip3 install <PACKAGENAME>
## Sources
- https://youtu.be/zsYIw6RXjfM

16
api/main.py Normal file
View file

@ -0,0 +1,16 @@
from flask import Flask, request, jsonify, redirect
app = Flask(__name__)
@app.route("/hello")
def helloWorld():
return "Hello World"
@app.route("/<slug>")
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)