Downloads · 30 days
0
MoneyMake420/Buisness
Buisness is a machine learning model from MoneyMake420. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
from flask import Flask, request, jsonify from flasksqlalchemy import SQLAlchemy from flaskjwtextended import ( JWTManager, createaccesstoken, jwtrequired, getjwtidentity ) from datetime import datetime import uuid
Downloads · 30 days
0
Access
Public
Updated Dec 9, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md4.4 KB · 75%
From the Hugging Face model README
from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy from flask_jwt_extended import ( JWTManager, create_access_token, jwt_required, get_jwt_identity ) from datetime import datetime import uuid
app = Flask(name) app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///marketplace.db" app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False app.config["JWT_SECRET_KEY"] = "super-secret-key"
db = SQLAlchemy(app) jwt = JWTManager(app)
class User(db.Model): id = db.Column(db.String, primary_key=True) username = db.Column(db.String, unique=True) password = db.Column(db.String) created_at = db.Column(db.DateTime, default=datetime.utcnow)
class Listing(db.Model): id = db.Column(db.String, primary_key=True) title = db.Column(db.String) description = db.Column(db.String) price = db.Column(db.Float) category = db.Column(db.String) location = db.Column(db.String) seller_id = db.Column(db.String) created_at = db.Column(db.DateTime, default=datetime.utcnow) ai_score = db.Column(db.Float, default=0)
def ai_price_suggestion(title, price): if "iphone" in title.lower(): return price * 1.1 return price
def ai_moderation(text): banned = ["scam", "fake", "illegal"] return not any(word in text.lower() for word in banned)
def ai_rank(listing): score = 0 score += max(0, 100 - listing.price) if "new" in listing.description.lower(): score += 20 return score
@app.route("/auth/register", methods=["POST"]) def register(): data = request.json user = User( id=str(uuid.uuid4()), username=data["username"], password=data["password"] ) db.session.add(user) db.session.commit() return jsonify(msg="registered")
@app.route("/auth/login", methods=["POST"]) def login(): data = request.json user = User.query.filter_by(username=data["username"], password=data["password"]).first() if not user: return jsonify(error="invalid credentials"), 401 token = create_access_token(identity=user.id) return jsonify(token=token)
@app.route("/listings", methods=["POST"]) @jwt_required() def create_listing(): user_id = get_jwt_identity() data = request.json
if not ai_moderation(data["title"] + data["description"]):
return jsonify(error="Listing rejected by AI moderation"), 400
suggested_price = ai_price_suggestion(data["title"], data["price"])
listing = Listing(
id=str(uuid.uuid4()),
title=data["title"],
description=data["description"],
price=suggested_price,
category=data.get("category"),
location=data.get("location"),
seller_id=user_id
)
listing.ai_score = ai_rank(listing)
db.session.add(listing)
db.session.commit()
return jsonify(msg="listing created", price=suggested_price)
@app.route("/listings", methods=["GET"]) def feed(): listings = Listing.query.order_by(Listing.ai_score.desc()).all() return jsonify([ { "id": l.id, "title": l.title, "price": l.price, "location": l.location, "score": l.ai_score } for l in listings ])
@app.route("/listings/search") def search(): q = request.args.get("q", "") results = Listing.query.filter(Listing.title.contains(q)).all() return jsonify([ {"title": l.title, "price": l.price} for l in results ])
@app.route("/ai/command", methods=["POST"]) @jwt_required() def ai_command(): text = request.json.get("prompt").lower()
if "show stats" in text:
return jsonify(
users=User.query.count(),
listings=Listing.query.count()
)
return jsonify(msg="AI command processed")
@app.route("/") def status(): return jsonify( app="AI Marketplace", status="running", listings=Listing.query.count() )
with app.app_context(): db.create_all()
if name == "main": app.run(debug=True)