#Python Flask Project Deploy
15 messages · Page 1 of 1 (latest)
What's the code?
Could you please check the Network logs when you click the Logs button?
its a python project for stored fetch information through API.
Yes, but are you following the typical appwrite function structure and returning a response?
Can you provide an exaple to reproduce the issue?
Where i can check it?
Browser console logs
If the logs modal isn't opening, I'd start there
Well, also the network tab logs
You probably can't just deploy a flask app.
Look at the docs for how to implement an Appwrite function: https://appwrite.io/docs/products/functions/develop
`from functools import wraps
from flask import Flask, request, jsonify
from flask_cors import CORS
from cachetools import TTLCache
import json
import asyncio
import lib2
app = Flask(name)
CORS(app)
Create a cache with a TTL (time-to-live) of 300 seconds (5 minutes)
cache = TTLCache(maxsize=100, ttl=300)
def cached_endpoint(ttl=300):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
cache_key = (request.path, tuple(request.args.items()))
if cache_key in cache:
return cache[cache_key]
else:
result = func(*args, **kwargs)
cache[cache_key] = result
return result
return wrapper
return decorator
curl -X GET 'http://127.0.0.1:3000/api/account?uid=1813014615®ion=ind'
@app.route('/api/account')
@cached_endpoint()
def get_account_info():
region = request.args.get('region')
uid = request.args.get('uid')
if not uid:
response = {
"error": "Invalid request",
"message": "Empty 'uid' parameter. Please provide a valid 'uid'."
}
return jsonify(response), 400, {'Content-Type': 'application/json; charset=utf-8'}
if not region:
response = {
"error": "Invalid request",
"message": "Empty 'region' parameter. Please provide a valid 'region'."
}
return jsonify(response), 400, {'Content-Type': 'application/json; charset=utf-8'}
try:
return_data = asyncio.run(lib2.GetAccountInformation(uid, "7", region, "/GetPlayerPersonalShow"))
# Patch: Replace clothes with equipedSkills if present
if "profileInfo" in return_data:
profile = return_data["profileInfo"]
if "equipedSkills" in profile:
profile["clothes"] = profile["equipedSkills"]
del profile["equipedSkills"]
formatted_json = json.dumps(return_data, indent=2, ensure_ascii=False)
return formatted_json, 200, {'Content-Type': 'application/json; charset=utf-8'}
except Exception as e:
return jsonify({
"error": "Server error",
"message": str(e)
}), 500, {'Content-Type': 'application/json; charset=utf-8'}
if name == 'main':
app.run(port=3000, host='0.0.0.0', debug=True)`
Here is my main code (app.py)
Here is my Project Domain: https://682acf17c19d7786ecf6.fra.appwrite.run/
FYI, it's best to use 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting).
again, look at the docs for how to implement an Appwrite function: https://appwrite.io/docs/products/functions/develop