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)

推荐歌曲

Brutal Anthem
Brutal Anthem

glitch metal experimental future bass prog metal

street dance soul
street dance soul

romantic soul

달을 위한 항변(Lyrics by epoh)
달을 위한 항변(Lyrics by epoh)

Acoustic Guitar, Piano, Female vocal, Major, Bossa Nova, aggradevole, bewegt

Emerald Fisted Lion
Emerald Fisted Lion

male vocalist,rock,folk rock,celtic rock,melodic

Love is All
Love is All

pop catchy upbeat

Krysy z Periferie
Krysy z Periferie

český drum and bass underground energický

Kaleidoscope of Lights
Kaleidoscope of Lights

progressive rock meets cumbia, trumpets

Souls Dewata Island
Souls Dewata Island

tropical pop upbeat

Скейтборд в очке
Скейтборд в очке

pop punk, punk rock, ska punk, male lyrics voice

Sweet Words
Sweet Words

mellow synthpop

111
111

Taiko, lute, Guzheng, Shamisen,

Lean on You
Lean on You

Female singer Ballad song K-POP emo  EDM Romantic Calm

Social Echoes
Social Echoes

male vocalist,rock,alternative rock,indie rock,rhythmic,energetic,quirky,playful,slacker rock,noise pop,noisy,dense,dissonant,raw

<1>아름다운과거
<1>아름다운과거

psychedelic rock experimental j-pop

City Nights
City Nights

house, EDM, slap house, deep house, brazilian bass

Electrified Hustle
Electrified Hustle

trap high-energy hip hop

Lập Trình Game
Lập Trình Game

acoustic, emotional, pop, melodic, 90s