qpython-android / qpython3-toolchain

qpython3-toolchain is a tools collection, helping you build QPython3's core from source code.
Do What The F*ck You Want To Public License
2 stars 3 forks source link

working path for file load is "/"? #3

Open rudi48 opened 9 years ago

rudi48 commented 9 years ago

Hello, I try to use the web framework bottle, with an application, which works on Ubuntu 14.04. When I try to load my template file from the web browser (firefox): return template('index.tpl', **settings) I will get an HTML error 500 (internal server error). When I try to load a static file, I will get an HTML error 404 (file not found).

When I run in a test program: print(os.path.abspath(os.getcwd())) I will get just "/".

Usually in "bottle" the program directory is the root for file loads. How can I set it up, to make the root for file loads the program directory?

Regards, Rudolf

riverfor commented 9 years ago

You should write the absolute path in QPython3 or QPython.

On Thu, Jun 4, 2015 at 5:15 PM, rudi48 notifications@github.com wrote:

Hello, I try to use the web framework bottle, with an application, which works on Ubuntu 14.04. When I try to load my template file from the web browser (firefox): return template('index.tpl', **settings) I will get an HTML error 500 (internal server error). When I try to load a static file, I will get an HTML error 404 (file not found).

When I run in a test program: print(os.path.abspath(os.getcwd())) I will get just "/".

Usually in "bottle" the program directory is the root for file loads. How can I set it up, to make the root for file loads the program directory?

Regards, Rudolf

— Reply to this email directly or view it on GitHub https://github.com/qpython-android/QPython3-core/issues/3.

river's showtime, river's game

rudi48 commented 9 years ago

Hello riverfor,

Thank you very much for your hint.

I wanted to have a solution, which is good for several OS.

My working universal solution was:

    # if system Android, set root directory, *** needs to be adopted
    import platform
    machine = platform.machine()
    print('machine: ' + machine)
    if (machine == 'armv7l'):
            os.chdir('/sdcard/com.hipipal.qpyplus/projects3/LabPSU2m')
    print(os.getcwd())

I hoped, you had a better idea for universal use.

Best regards, Rudolf