Python

August 3rd, 2024suno

歌词

from flask import Flask, request, jsonify from flask_sqlalchemy import SQLAlchemy from flask_cors import CORS app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///functions.db' db = SQLAlchemy(app) CORS(app) class Function(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), nullable=False) description = db.Column(db.String(200), nullable=False) language = db.Column(db.String(100), nullable=False) with app.app_context(): db.create_all() @app.route('/api/functions', methods=['GET']) def get_functions(): functions = Function.query.all() results = [ { 'id': func.id, 'name': func.name, 'description': func.description, 'language': func.language } for func in functions ] return jsonify(results) @app.route('/api/functions/search', methods=['GET']) def search_functions(): query = request.args.get('query', '') language = request.args.get('language', '') functions = Function.query.filter( Function.description.ilike(f'%{query}%'), Function.language.ilike(f'%{language}%') ).all() results = [ { 'id': func.id, 'name': func.name, 'description': func.description, 'language': func.language } for func in functions ] return jsonify(results) @app.route('/api/functions', methods=['POST']) def add_function(): data = request.get_json() if 'name' not in data or 'description' not in data or 'language' not in data: return jsonify({'error': 'Bad Request', 'message': 'Missing name or description or language'}), 400 new_function = Function(name=data['name'], description=data['description'], language=data['language']) db.session.add(new_function) db.session.commit() return jsonify({'message': 'Function added'}), 201 @app.route('/api/functions/<int:id>', methods=['DELETE']) def delete_function(id): function = Function.query.get_or_404(id) db.session.delete(function) db.session.commit() return jsonify({'message': 'Function deleted'}) if __name__ == '__main__': app.run(debug=True)

推荐歌曲

Whispers on wings
Whispers on wings

An Angelic slow molidic bass boosted Lofi EDM with pianno in style with Female intense clear vocals

Youth
Youth

dub, Iceland folk, lo-fi, child choir, indie folk

Trường  Việt Hùng của em
Trường Việt Hùng của em

vocaloid, funk, ambient, uplifting

Nicole
Nicole

slow, guitar, drum

Rise Up to the Stars
Rise Up to the Stars

psychedelic rock 1980s radio-friendly

In the Light
In the Light

Eyedress's style. Fuse dream pop, lo-fi indie, and electronic elements to craft a hazy, atmospheric soundscape

Moonbound Howl [8-bit version]
Moonbound Howl [8-bit version]

Chiptune, 8-bit, electronic, upbeat, video game-inspired

Lucy
Lucy

Chill out

ひとりぼっちの幸せ
ひとりぼっちの幸せ

ポップ、メロディック、アコースティック

จินตนาการ
จินตนาการ

cinematic, edm, pop, math rock

Happy Earth
Happy Earth

Balad Sad Die

RadioShack
RadioShack

1970s alternative hard rock, radio shack

Angel
Angel

Opera ethereal grunge metal scremo

Donne-moi le style
Donne-moi le style

Male vocal Yong , pop romantique , légère et entraînante.

Mysterious Hope
Mysterious Hope

Haunting, deep, bass, piano, sad, dubstep, folk

of course, we can, try, but not quite, fly high enough
of course, we can, try, but not quite, fly high enough

glitch minimalist contemporary classical crossover, deep barrels, dominant male voices, harmonies with altos/sopranos

全.剧终
全.剧终

都市民谣, 抒情, Unisex Vocal, 50 BPM, F大调, 电子琴 & 木吉他 & 弦乐

Guarda-Chuva
Guarda-Chuva

softcore, male voice,