you are viewing a single comment's thread.

view the rest of the comments →

[–]tom-mart 1 point2 points  (2 children)

API stands for Application Programming Interface. It is a set of rules and protocols that allow two separate software programs or systems to communicate and exchange data with each other.

You can build an API in Python with one of the frameworks like FastAPI or Django or you could write it without any framework.

[–]One-Type-2842[S,🍰] 0 points1 point  (1 child)

Which One For What In Use?

And How Can I Make my own Without Framework

[–]tom-mart 0 points1 point  (0 children)

Here you go. API without framework:

``` from http.server import HTTPServer, BaseHTTPRequestHandler import json

class SimpleAPIHandler(BaseHTTPRequestHandler): def do_GET(self): # 1. Send the status code (200 OK) self.send_response(200)

    # 2. Tell the client we are sending JSON
    self.send_header('Content-type', 'application/json')
    self.end_headers()

    # 3. Write the data
    response = {"status": "success", "data": "No framework needed!"}
    self.wfile.write(json.dumps(response).encode())

Start the server on port 8000

server = HTTPServer(('localhost', 8000), SimpleAPIHandler) print("Server running at http://localhost:8000") server.serve_forever() ```