FileSystemException: Cannot open file, path = 'file:///usr/local/server/src/static/index.html' (OS E
- 1
- Self Hosted
- Functions

Just copied the util.dart file

To my code

And pushed using the CLI

What's your folder structure and what's the function in your appwrite.json?


"projectId": "64fff1b78429690cbb74",
"projectName": "windope",
"functions": [
{
"$id": "65480141667102a7bf37",
"name": "site",
"runtime": "dart-2.17",
"execute": [],
"events": [],
"schedule": "",
"timeout": 15,
"enabled": true,
"logging": true,
"entrypoint": "lib/main.dart",
"commands": "dart pub get",
"ignore": [
".packages",
".dart_tool"
],
"path": "./"
}
]
}

final String _dirname = Platform.script.toFilePath();
final String staticFolder = '${Uri.file(_dirname).resolve('../static')}';
/// Throws an error if any of the keys are missing from the object
/// @param obj - The object to check
/// @param keys - The list of keys to check for
/// @throws Exception
void throwIfMissing(Map<String, dynamic> obj, List<String> keys) {
final missing = <String>[];
for (var key in keys) {
if (!obj.containsKey(key) || obj[key] == null) {
missing.add(key);
}
}
if (missing.isNotEmpty) {
throw Exception('Missing required fields: ${missing.join(', ')}');
}
}
/// Returns the contents of a file in the static folder
/// @param fileName - The name of the file to read
/// @returns Contents of static/{fileName}
Future<String> getStaticFile(String fileName) {
return File('index.html').readAsString();
}

even I have done this dart return File('index.html').readAsString();

Look at the files in the template. The html file should be in a folder named static

yes I have done that only in the begning

still same error

What?

return File('index.html').readAsString();
}
``` have hardcored the file path

Have you tried doing it as the template does?

In the starting I have followed the same file structure

Yes I have

getting the same error

Please share what you have after you change it to what the template did

its simply serves a index.html on GET at /


hmm odd...let me check with the team

yes I am contributing to appwrite/template ,

pull request just pending on this @Drake

For now, you might want to put a string in your code rather than trying to have a static file

I'm experiencing the same problem. any solution?
Error:- PathNotFoundException: Cannot open file, path = 'file:///usr/local/server/src/static/index.html' (OS Error: No such file or directory, errno = 2)
Recommended threads
- SMTP Error: Could not connect to SMTP
My appwrite self-hosted instance on DigitalOcean cannot sennd emails. The following results were performed Log: ``` docker compose logs -f appwrite-worker-mail...
- Cannot create a user
Hi, I am using a lowcoder frontend and trying to create a user in Appwrite (python function). Unfortunately, all I got is an error: "Raw body: Error". It means...
- Where is tensorflow support? 3.11 ML doe...
and if i manually tried to add tensorflow i get Cannot access offset of type string on string no matter what
