File size: 902 Bytes
ee49611
 
 
 
 
 
 
 
 
 
 
 
 
541820f
ee49611
541820f
 
 
 
 
 
 
 
 
ee49611
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flask import Flask, request, jsonify
import asyncio
from hypercorn.asyncio import serve
from hypercorn.config import Config
import os
os.environ['CURL_CA_BUNDLE'] = ''



app = Flask(__name__)
transcriptions = {}


@app.route('/<username>', methods=['POST', 'GET'])
def handle_transcription(username):
    if request.method == 'POST':
        data = request.get_json()
        transcription = data.get('transcription', '')
        transcriptions[username] = transcription  # Store the transcription
        return jsonify({"status": "success", "message": "Transcription received"})
    elif request.method == 'GET':
        transcription = transcriptions.get(username, 'N/A')
        return jsonify({"transcription": transcription})
    

if __name__ == "__main__":
   config = Config()
   config.bind = ["0.0.0.0:7860"]  # You can specify the host and port here
   asyncio.run(serve(app, config))