1

I am making an online judge in Django. I am taking user code in a file and then compile it and running it and giving the verdict. for example let say a user submitted code in c++ language so I am taking that code in a .cpp file and compile it and running it and I am doing it by giving the absolute path of my .cpp file like E:\online_judge_project\oj\language\forcpp.cpp

my problem is that when I will deploy my project it will cause error because this paths are my local machine path and I can't use that in deployment so how will I access the files( like .cpp file) after the deployment. Although those files are in my project directory only and I kept them in a folder name language. my project directory structure is like:

enter image description here

I am thinking of using os.join.path() but I am not getting how to do that.

1 Answer 1

2

did you consider putting your cpp file inside static files and define STATIC_URL and STATICFILES_DIRS in your setting.py

you can put in the function you are using cpp file

import os
print(os.getcwd())

this script to know exact location of your script and put cpp file in the same path then you should can access it

Sign up to request clarification or add additional context in comments.

2 Comments

actually No can we do that like static files are the .css, .js files right ???
i edited the answer, you can do 'os.getcwd())' this return the function's script path then if you put cpp file inside the same path you should access it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.