If you're freelance then it's really up to you. I wouldn't recommend going the lines-of-code route, it doesn't really correlate well to the amount of build effort or the quality of the final output.
As a freelancer you'll most likely be picking up work on a per-project basis, so my suggestion (and what I do personally) is to negotiate each project on an individual basis and provide each client with at least a couple of options on pricing. The options I provide are fixed-price and billed-hourly. The first option has proven to be much more popular, as in general people seem to prefer having a fixed, known cost rather than hourly charges that might accrue up to who knows what final amount.
Note that with any sort of fixed-price arrangement it's important to have a very clear spec before you provide your quote, and to make it clear that anything that the client adds outside of that spec is a change request and will be billed separately.
There's really no universal approach to setting a price, and what's "fair" is generally considered to be whatever the market will bear. Obviously if you build up a record as an awesome freelance developer you can charge more for the same project than someone who has no prior history to back up their freelancing skills.
My suggestion would be to look at the requirements for a project, and work out how long you think it would take to implement, in person-hours. Then take the smallest hourly rate that you feel does not undervalue your time and multiply it by your estimate, and that'll give you the minimum price that you should accept for the project. You can then negotiate down from a starting price that is higher than your minimum price, and after doing a few like that you'll start to get a feel for how much you can expect to be able to charge for a project of a given scope. Note that this only works if you're good at estimating development effort from requirements, which is a difficult to learn skill in and of itself.