initial checkin
doing my first checkin. initial stuff.
This commit is contained in:
BIN
FlaskHISLaunchpad/.DS_Store
vendored
Normal file
BIN
FlaskHISLaunchpad/.DS_Store
vendored
Normal file
Binary file not shown.
26
FlaskHISLaunchpad/app.py
Normal file
26
FlaskHISLaunchpad/app.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Fri Oct 3 00:59:15 2025
|
||||
|
||||
@author: dromisch
|
||||
"""
|
||||
|
||||
from flask import Flask
|
||||
from route1 import route1 # Import the Blueprint
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# Register the Blueprint
|
||||
app.register_blueprint(route1)
|
||||
|
||||
# SQLAlchemy Configuration
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'mssql+pyodbc://hangfire_api:hangfire_123@SCHHISSQL/HISApps?driver=ODBC+Driver+17+for+SQL+Server'
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
|
||||
# Initialize SQLAlchemy
|
||||
db = SQLAlchemy(app)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
54
FlaskHISLaunchpad/route1.py
Normal file
54
FlaskHISLaunchpad/route1.py
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Fri Oct 3 00:59:15 2025
|
||||
|
||||
@author: dromisch
|
||||
"""
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
route1 = Blueprint('route1', __name__)
|
||||
|
||||
# Data storage
|
||||
data = [
|
||||
{"id": 1, "name": "Item 1"},
|
||||
{"id": 2, "name": "Item 2"}
|
||||
]
|
||||
|
||||
# Get all items
|
||||
@route1.route('/items', methods=['GET'])
|
||||
def get_items():
|
||||
return jsonify(data)
|
||||
|
||||
# Get a single item by ID
|
||||
@route1.route('/items/<int:item_id>', methods=['GET'])
|
||||
def get_item(item_id):
|
||||
item = next((item for item in data if item["id"] == item_id), None)
|
||||
if item:
|
||||
return jsonify(item)
|
||||
return jsonify({"error": "Item not found"}), 404
|
||||
|
||||
# Create a new item
|
||||
@route1.route('/items', methods=['POST'])
|
||||
def create_item():
|
||||
new_item = request.json
|
||||
data.append(new_item)
|
||||
return jsonify(new_item), 201
|
||||
|
||||
# Update an item
|
||||
@route1.route('/items/<int:item_id>', methods=['PUT'])
|
||||
def update_item(item_id):
|
||||
item = next((item for item in data if item["id"] == item_id), None)
|
||||
if item:
|
||||
updated_data = request.json
|
||||
item.update(updated_data)
|
||||
return jsonify(item)
|
||||
return jsonify({"error": "Item not found"}), 404
|
||||
|
||||
# Delete an item
|
||||
@route1.route('/items/<int:item_id>', methods=['DELETE'])
|
||||
def delete_item(item_id):
|
||||
global data
|
||||
data = [item for item in data if item["id"] != item_id]
|
||||
return jsonify({"message": "Item deleted"}), 200
|
||||
Reference in New Issue
Block a user